Skip to content

Database fixtures considered harmful. #116

Open
@proofit404

Description

@proofit404
Contributor

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.

Activity

changed the title [-][Blog] Database fixtures considered harmful.[/-] [+]Database fixtures considered harmful.[/+] on Jul 21, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @proofit404

        Issue actions

          Database fixtures considered harmful. · Issue #116 · dry-python/dry-python.github.io