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

Support fixture-style test wrappers #52

Open
greglook opened this issue Sep 22, 2020 · 0 comments · May be fixed by #56
Open

Support fixture-style test wrappers #52

greglook opened this issue Sep 22, 2020 · 0 comments · May be fixed by #56

Comments

@greglook
Copy link
Contributor

It would be great to support wrapper functions which can be called around tests and optionally around each step. This could be used similar to clojure.test fixtures, but we don't really need to do common setup/teardown since greenlight already has facilities for that. Instead, we want to use this to add observability aspects to the tests to integrate them with tracing tools like honeycomb.

robhanlon22 added a commit to robhanlon22/greenlight that referenced this issue Jun 9, 2022
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.
@robhanlon22 robhanlon22 linked a pull request Jun 9, 2022 that will close this issue
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 a pull request may close this issue.

1 participant