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

Database fixtures considered harmful.

Đang mở
#116 0 bình luận 0 reaction 0 người được giao Xem trên GitHub
blog
Ngôn ngữ chính
HTML
Star
10
Fork
5
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

#### 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.

Hướng dẫn đóng góp

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.