If you create your own test runner or use one from the community, it can be useful to add snippets of test configuration when running the test command.
The test snippets can be configured in workspace.edn under :test-configs
(see the test-runners example):
{
...
:test {:create-test-runner org.corfield.external-test-runner.interface/create}
:test-configs {:default-test-runner {:create-test-runner [:default]}
: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-dummy {:org.corfield/external-test-runner {:focus {:exclude [:dummy]}}}
:exclude-integration {:org.corfield/external-test-runner {:focus {:exclude [:integration]}}}}}
...
}
If we run the test command, e.g. poly test
, then the test configuration specified by the :test
key will be passed to the test runner(s). Let’s start a shell and verify this, from the examples/test-runners directory:
Now you can check the content of the :test
key:
test-runners$ ws get:settings:test
{:create-test-runner org.corfield.external-test-runner.interface/create}
Yes, it looked the same. Let’s use the default test runner:
test-runners$ ws get:settings:test with:default-test-runner
{:create-test-runner [:default]}
The old org.corfield.external-test-runner.interface/create
value was replaced by [:default]
.
If the old value instead was set to [org.corfield.external-test-runner.interface/create]
then the two vectors would instead been merged into [org.corfield.external-test-runner.interface/create :defalt]
.
Both default-test-runner
and kaocha-test-runner
store their values in a vector, and if we select both, the result will be merged:
test-runners$ ws get:settings:test with:default-test-runner:kaocha-test-runner
{:create-test-runner [:default polylith-kaocha.test-runner/create]}
Here is another example, where :integration
and :dummy
are concatenated:
test-runners$ ws get:settings:test with:exclude-integration:exclude-dummy
{:create-test-runner org.corfield.external-test-runner.interface/create,
:org.corfield/external-test-runner {:focus {:exclude [:integration :dummy]}}}
Now when we understand how test configuration can be added, we can run the test command using the default test runner:
test-runners$ test with:default-test-runner