dry-python / dry-python/dry-python.github.io

Database fixtures considered harmful.

未關閉
#116 0 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視
blog
主要語言
HTML
星號
10
分支
5
PR 合併指標
30 天內沒有已合併 PR

描述

#### An article about better test fixtures
* `dependencies` can turn `stories` **business objects** into pytest fixtures.
* We will write better tests because our database fills up logic **does not duplicate** in `FactoryBoy`.
* `@value` decorator can be used to return normal results from the factories.
```python
@register
class SubmitCodeFixture(SubmitCode):

name = 'submit_code'

@value
def fixture(submit_code, user, token):
return submit_code(user, token)

user = require('request_code')

token = Faker('uuid')
```
* **profit**: Tests coupled with business logic will fail if this logic changes. On the other side, we'll need to change each `FactoryBoy` usage in our test suite to mirror actual behavior.

貢獻指南

這個儲存庫沒有索引到貢獻指南

評估

這個 Issue 還沒有評估資料。

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。