polylith icon indicating copy to clipboard operation
polylith copied to clipboard

Support snippets of test configuration to be merged into settings

Open tengstrand opened this issue 10 months ago • 1 comments

There is a need for test configuration to be merged into the settings, e.g. when running the external test runner, see this comment.

We could solve this by adding a :test-configs key to workspace.edn, e.g.

{
 ...
 :test-configs {:external-test-runner {:create-test-runner [org.corfield.external-test-runner.interface/create]}
                :kaocha-test-runner   {:create-test-runner polylith-kaocha.test-runner/create}
                :exclude-stuff        {:org.corfield/external-test-runner {:focus {:exclude [:stuff]}}}}}
                :exclude-integration  {:org.corfield/external-test-runner {:focus {:exclude [:integration]}}}
}

The Kaocha test runner can now be selected with:

poly test with:kaocha-test-runner

Or the External test runner, without the integration tests:

poly test with:external-test-runner:exclude-integration

The idea is that the selected configuration snippets will be merged to the :test key in the workspace configuration, and if the value lives in a collection (e.g. vector or hash map) it will be added to existing values, e.g.:

poly test with:external-test-runner:exclude-integration:exclude-stuff

Will end up as:

:test {:create-test-runner [org.corfield.external-test-runner.interface/create]
       :org.corfield/external-test-runner {:focus {:exclude [:integration :stuff]}}}

If we run commands from a shell, we will also get autocomplete for the with option.

tengstrand avatar Mar 29 '24 09:03 tengstrand

That's nice -- it wouldn't support complete ad hoc test settings (per my original discussion on Slack) but it would make it much less verbose to support a specific set of test settings which should be sufficient, and it would be no big deal to add more :test-configs as needed for a given project for any combination of additional settings. A good compromise, esp. with the auto-complete support this would bring.

seancorfield avatar Mar 29 '24 18:03 seancorfield

Nice! I'll finish up my work on https://github.com/seancorfield/polylith-external-test-runner/issues/5 and https://github.com/seancorfield/polylith-external-test-runner/issues/6 and document usage per this new machinery in Polylith.

seancorfield avatar Jun 20 '24 06:06 seancorfield