Skip to content

Excluding and/or including certain tests via metadata #126

Description

@pithyless

Is your feature request related to a problem? Please describe.

I would like to write tests that should not always be run, eg:

  • benchmarking/performance tests that take too long to be run every time
  • integration tests with external systems that rely on working VPN, etc. and cannot be run in all environments.

Describe the solution you'd like

The cognitect.test-runner supports this via keyword options:

  :includes - coll of test metadata keywords to include
  :excludes - coll of test metadata keywords to exclude

The filter is applied to which vars will be run: https://github.com/cognitect-labs/test-runner/blob/334f2e2a5491747dff52f9ca8cbb4a53f54d344d/src/cognitect/test_runner.clj#L27-L32

I think a solution could be to similarly support filtering out specific metadata keywords before generating the final test-statements (after all the other logic for which bricks have changed, etc):

test-statements (mapv ->test-statement (concat brick-test-namespaces project-test-namespaces))

The other question would be where to configure the inclusion/exclusions. Perhaps a combo of having defaults configured in the workspace.edn and support for passing specific exclusion/inclusion keywords via poly test?

Describe alternatives you've considered

Right now, these kind of tests:

  • need to be commented out and run manually (e.g. via a REPL inside a rich-comment-form)
  • defined in a separate project that will need to be excluded by default in poly tooling
  • perhaps not defined as tests but separate main executables that are run from root (but then we're reinventing the test-runner framework for reporting, etc)

I would prefer if they would be first-class deftest vars that are tagged via metadata and a way of excluding/including the tags via the poly test CLI. Bonus points if we can have poly CLI report that X number of tests were skipped.

Additional context

Kaocha test-runner also has a similar feature via:

Kaocha supports both filtering via metadata on the test-var and on the namespace. I would not consider the latter strictly necessary, but it is interesting to consider.

Metadata

Metadata

Assignees

Labels

cliRelated to Polylith clicoreRelated to core functionality of PolylithimprovementNot a bug but an improvement to overall user experience

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions