Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for fixtures #56

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

robhanlon22
Copy link
Contributor

Resolves #52.

This is a first pass for this feature so design input is requested.

Initial decisions:

  • Use use-fixtures from clojure.test for fixture functions that
    apply to all of the tests in a namespace. Note that this does not
    support :once fixtures as of yet because the runner does not run all
    tests in a namespace as a group that can be :onced. This will
    require a change to greenlight.runner.
  • Add ::test/each as an option to the deftest attribute map. This
    needs to be a collection of fixture functions. This could not quite be
    expressed via the use-fixtures method because it would unilaterally
    apply a fixture function to all steps in all tests in a namespace.
    This could be an additional feature as well.

Open questions:

  • Are functions expressive enough, or should this introduce a new
    namespace that allows for composable definitions of fixtures in the
    way that steps are composable? Something like deffixture, a
    greenlight-specific use-fixture for top-level, and then fixture
    configuration at the test/step level.
  • Should context be passed into the fixture functions, and should it be
    modifiable by the fixture functions? e.g., should downstream steps see
    the changed context and should the test output contain that changed
    context. This gets a bit sticky and pushes on the deffixture idea,
    in that greenlight tries to be explicit about its data dependencies
    and outputs, but with fixtures that can take/update context, declaring
    data dependencies gets a bit hairier. I can imagine that deffixture
    would also declare inputs and outputs, which could then get merged
    into the step inputs/outputs. Depends on how complex this needs to be.

Resolves amperity#52.

This is a first pass for this feature so design input is requested.

Initial decisions:

- Use `use-fixtures` from `clojure.test` for fixture functions that
  apply to all of the tests in a namespace. Note that this does not
  support `:once` fixtures as of yet because the runner does not run all
  tests in a namespace as a group that can be `:once`d. This will
  require a change to `greenlight.runner`.
- Add `::test/each` as an option to the `deftest` attribute map. This
  needs to be a collection of fixture functions. This could not quite be
  expressed via the `use-fixtures` method because it would unilaterally
  apply a fixture function to all steps in all tests in a namespace.
  This could be an additional feature as well.

Open questions:
- Are functions expressive enough, or should this introduce a new
  namespace that allows for composable definitions of fixtures in the
  way that steps are composable? Something like `deffixture`, a
  greenlight-specific `use-fixture` for top-level, and then fixture
  configuration at the test/step level.
- Should context be passed into the fixture functions, and should it be
  modifiable by the fixture functions? e.g., should downstream steps see
  the changed context and should the test output contain that changed
  context. This gets a bit sticky and pushes on the `deffixture` idea,
  in that greenlight tries to be explicit about its data dependencies
  and outputs, but with fixtures that can take/update context, declaring
  data dependencies gets a bit hairier. I can imagine that `deffixture`
  would _also_ declare inputs and outputs, which could then get merged
  into the step inputs/outputs. Depends on how complex this needs to be.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support fixture-style test wrappers
1 participant