cargo test "0 tests run" / all filtered out in CI
cargo test succeeded but ran zero tests. This passes the job while testing nothing: a name filter matched nothing, the test target was excluded, or a feature that gates the tests was off in CI.
What this error means
cargo test exits 0 with "running 0 tests" and "test result: ok. 0 passed; 0 failed; N filtered out", even though tests exist in the crate.
running 0 tests
test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 12 filtered out; finishedCommon causes
A name filter that matched no tests
An argument after -- is treated as a test name filter; a typo or a stale name filters every test out, so none run.
Tests gated behind a feature not enabled in CI
Tests inside #[cfg(feature = "X")] modules do not compile in when that feature is off, so the binary contains zero tests.
How to fix it
Run without a filter and enable test features
- Remove any stray name filter after
--so all tests are selected. - Enable the features that gate the tests (or use
--all-features). - Confirm the count is non-zero and matches what you expect.
cargo test --all-features --workspaceFail the job when no tests run
Make an empty run visible instead of green by asserting tests executed.
cargo test --workspace 2>&1 | tee out.txt
grep -q 'running 0 tests' out.txt && { echo 'no tests ran'; exit 1; } || trueHow to prevent it
- Run tests with the feature set your suite expects (
--all-features). - Avoid stray positional args that become silent name filters.
- Guard against accidental empty runs in CI.