-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cargo test --tests
also runs unit tests -- target filters are confusing
#10936
Comments
Totally agree it is confusing. People usually invoke It's hard to encourage people to use Footnotes
|
So is there even a way to ask cargo to test (or check or ...) all test targets (the things that are by default in the |
Oh wow, I had no idea that this command even existed! Thanks for pointing it out, I will try to remember. :) I now see it is mentioned at the end of What's the reason why |
Underneath the hod, integration tests and unit tests are handled by the same mechanism. They are all collected from functions with
I got a impression that @epage had mentioned it somewhere but can't remember. |
Ah, didn't know that was possible, thanks. I should really read those long docs in their entirety. Still I feel like a flag is missing here, since we do have such a flag for all other similar cases, AFAIK. |
The description of
But there seems to be a problem with this statement, the results of my tests using Also, in |
In case its relevant, #12915 made some minor wording tweaks in 1.75 |
Clarify the function of the test options ### What does this PR try to resolve? Make the description of test options clearer. from #10936
I think the main confusion is the fact that this is not equivalent to |
cargo test --help: clarify --tests and --benches This tries to reduce the confusion expressed in #10936. I am not sure what it means to "test a target in benchmark mode", this is copied verbatim from `cargo help test`.
Problem
cargo test
has flags--libs
,--bins
,--tests
,--doc
, which I thought (based on their documentation) would control whether the lib crate unit tests / bin crate unit tests / integration tests / doc tests, respectively, are being run. But that does not seem to be what happens, so either the documentation is wrong or it is very confusing.Steps
cargo test --tests
.cargo test --bins
runs only the binary crate unit tests.This seems clearly inconsistent. I would expect
cargo test --tests
to be the same ascargo test --test a --test b
(manually listing all tests), which is howcargo test --bins
seems to behave.Possible Solution(s)
No response
Notes
Generally the
cargo test
documentation for all these many flags that control which tests are being run, is unclear on whether the flag adds tests to the default test set, or remove the default test set to only run a small select set of tests. (This also affects other commands likecargo check
.) For instance,cargo test --benches
tests more than the default test set, butcargo test --bins
tests less than the default test set, but the documentation for these two flags reads exactly the same. Some flags use the word 'only', which is maybe meant to indicate "reduce default test set", but--bins
does not use that word and anyway this is not at all clear.The behavior I would have expected is along the lines of "if any of these flags is present, then only what is specified by the flags is being run, no default test set", but that does not match implemented behavior. This then makes me wonder how I would even say "run only integration tests" (
cargo test --tests
doesn't do that), or "check only the benchmarks" (cargo check --benches
doesn't do that).Version
The text was updated successfully, but these errors were encountered: