-
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 --test <testname> builds binaries #7958
Comments
This is done intentionally so that integration tests can execute the binaries to exercise their behavior. Seems like it would be good to document that! In general the Cargo documentation on writing tests is a little shallow. |
Is there a way to build the tests without the binaries? Also, regarding documentation, according to the Cargo Book, it says:
and under the
implying there is a way to avoid the default behavior, and it also states that
implying that there is a way to build tests without binaries (since I propose these parts be rewritten for clarity. |
There is not currently a way to skip building the binaries. |
Seems a explanation for auto-build binaries is already there?
|
#10726 improves the doc a little. I'll close this issue as resolved. If you feel we need a fix other than a doc update, please file a new issue. Thank you! |
Oh, that was exactly the feature I was looking for 😕
|
Problem
The documentation for cargo seems to suggest that if I run:
cargo test --test apple
, then,this should run test
apple
without compiling any of the binaries. However, this doesn't seem to be the case.Steps
cargo new banana
.lib.rs
file insrc/
. My contents were:bin/
insrc/
then add a filerun.rs
; my contents were:tests/
at the project root. Add a simple test filesample.rs
with contents:cargo test --test sample
bin/run.rs
is compiled. We can tell since we can warnings about unused variables from it.Notes
Output of
cargo version
:The text was updated successfully, but these errors were encountered: