Skip to content
Latchkey

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.

cargo
running 0 tests

test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 12 filtered out; finished

Common 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

  1. Remove any stray name filter after -- so all tests are selected.
  2. Enable the features that gate the tests (or use --all-features).
  3. Confirm the count is non-zero and matches what you expect.
Terminal
cargo test --all-features --workspace

Fail the job when no tests run

Make an empty run visible instead of green by asserting tests executed.

.github/workflows/ci.yml
cargo test --workspace 2>&1 | tee out.txt
grep -q 'running 0 tests' out.txt && { echo 'no tests ran'; exit 1; } || true

How 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.

Frequently asked questions

What causes ""running 0 tests""?
An argument after -- is treated as a test name filter; a typo or a stale name filters every test out, so none run.
How do I fix "running 0 tests"?
Run without a filter and enable test features

Related guides

References

Latchkey auto-heals failures like this one - detected, fixed, and retried without you. Start free → 30-day trial · No credit card