dry-python / dry-python/dry-python.github.io
Database fixtures considered harmful.
- 主要语言
- 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 还没有评估数据。