I like to set up cargo watch to watch a file and run a unit test while I am working. I set up as follows:
cargo watch -q -c -w src/ -x 'test -q bcrypt_pwd -- --nocapture'
As requested, it only runs the one test. But then I get lots of lines like this for tests that aren't run:
...
running 0 tests
test result: ok. 0 passed...
...
This is annoying. Is there a way to just get output for the test I'm running?
You could be more specific about where that test comes from, like test --lib
, test --doc
, test --test foo
, etc. Then you shouldn't get "0 tests" from the rest of the sources.
1 Like
Thank you. I didn't understand that the multiple test "sources" would generate output even when not run. This fixed my problem.
They generate output because they do still run. The test name filtering is done by each test binary, not at the Cargo level, so Cargo just runs them all by default.