Database fixtures considered harmful.

Open
#116 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
35/100
Issue type
Documentation
Clarity
Needs clarification
Activity status
Stale
Tech stack
python

Research direction

No files, tests, or entry points are named; start by reviewing the website's existing article structure and the proposed fixture examples in this issue. Done means publishing an article that explains the database-fixture concerns, the dependencies and @value approach, and the trade-offs for existing FactoryBoy usages.

Written by the indexing model from the issue text.

Description

blog
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.
@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.
Dominant language
HTML
Stars
10
Forks
5
PR merge metrics
No merged PRs in 30d

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from dry-python/dry-python.github.io

All issues in dry-python/dry-python.github.io

Similar issues

More Content issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.