Cargo's built-in test runner does not support grouping tests, which can be a problem when some of your tests are reasource-intensive and you don't want to run them all at once. Nextest solves this problem by allowing you to define test groups using filter expressions in a config file and limit concurrently.
This works, but you may find yourself:
- Having very complex filter expressions that often go out-of-sync with code
- Or having a special module hierarchy for your tests, separating tests into modules like
heavy
,dockerized
etc. - this is not ideal because tests for the same component may now end up in different files, based on how "heavy" they are.
This tiny crate lets you group tests in code like so:
async
This will result in a code like this:
So that these tests will appear in nextest
as:
g3d6f::heavy::test_foo
g64dc::heavy::flaky::test_bar
Allowing you to filter tests by group in your .config/nextest.toml
as such:
[[]]
= 'test(::heavy::)'
= 1
[[]]
= 'test(::flaky::)'
= 3
Or when running as:
Note: The extra modules like
g3d6f
are generated by the macro to avoid module name collisions, as unlikeimpl
blocks you cannot have more than onemod X {}
in the same file. The names are based on a SHA hash of the test content to be stable but unique-ish.