Description
Problem
Context: I have many test targets and want to narrow down the scope of cargo test
while in the development loop. Regular test filtering still spends a bunch of time running targets that say ok. 0 passed
.
This interaction is frustrating:
$ cargo test --test foobar
error: no test target named `foobar`
Ok, great, but please tell me what the set of test targets is or how to find it. In this case, I want to run an integration test corresponding to a file tests/foobar.rs
, but not how to express that in the right format for --test
. Let's check the help:
$ cargo test --help
...
--test <NAME>... Test only the specified test target
That doesn't shine any more light on it. What is the set from which NAME is drawn? What's the "type", if you will?
Next I looked for something like --list-targets
but didn't find it.
Finally, I look through the output of cargo test
, hoping that it essentially serves the function of listing test targets. But the printouts during a test run look like this:
Running target/debug/deps/foobar-ed66a800a301dfb1
And that's clearly not the string I'm supposed to provide to --test
!
Solution
Here are three possible solutions:
- Provide a
cargo test --list
and mention it from thecargo test --test
error message. - Print out the list of literal target strings as part of the
cargo test --test
error message. This can be truncated if it's excessively long. - Print precise target strings in a clear way while running tests.
Related
It seems #8396 is the only other issue that mentions this error message.
There was also this very old #812 discussing the documentation for cargo test
vs cargo test --test
.