You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
pubfnmain(){#[cfg(test)]#[test]fnit_works(){panic!("Proof this test doesn't run");}}
I expect cargo test to run the unit test it_works. But this doesn't happen. cargo test doesn't run any tests:
running 0 tests
test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out
Additionally, rustc emits no warnings or errors when compiling this. The test is just silently excluded from the executable (verified by running otool and grepping for it_works).
rustc shouldn't exclude this test from the executable, and cargo test should run this test.
You might wonder why anyone would add a unit test within a function. My use case is a unit test injected by an attribute macro on a fn within an impl block (the attribute does many things to the function and adds the unit test to verify some parts that can't be validated at compile time).
Tested with rustc 1.27.0-nightly (91db9dcf3 2018-05-04) and cargo 1.27.0-nightly (af3f1cd29 2018-05-03).
The text was updated successfully, but these errors were encountered:
Consider the following program:
I expect
cargo test
to run the unit testit_works
. But this doesn't happen.cargo test
doesn't run any tests:Additionally,
rustc
emits no warnings or errors when compiling this. The test is just silently excluded from the executable (verified by runningotool
and grepping forit_works
).rustc
shouldn't exclude this test from the executable, andcargo test
should run this test.You might wonder why anyone would add a unit test within a function. My use case is a unit test injected by an attribute macro on a fn within an impl block (the attribute does many things to the function and adds the unit test to verify some parts that can't be validated at compile time).
Tested with
rustc 1.27.0-nightly (91db9dcf3 2018-05-04)
andcargo 1.27.0-nightly (af3f1cd29 2018-05-03)
.The text was updated successfully, but these errors were encountered: