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
{{ message }}
Repository navigation
When running with --test-modules and --filter, allow "zero tests ran" behavior to apply to entire run vs individual modules #7457
When using dotnet test with --test-modules and a --filter, it should be possible to request (via parameter) that the zero tests ran failure should happen for the entire run instead of for each module.
Background and Motivation
We frequently use a filter in our test runs to run subsets of tests, especially in pipelines. We might only run Priority 1 tests or run a category of tests for a product feature. When doing this, any module with no matches causes the "Zero tests ran" error to be output. With lots of test modules, this yields a lot of potential errors when we know some won't have a match for the filter.
Proposed Feature
I know it's possible to use --ignore-exit-code 8 to suppress the error entirely. However, it's still valuable to have a "zero tests ran" error for the full run instead of one per module. It would be beneficial to have a parameter that makes this behavior apply to the full run at a summary level.
I've also noticed --minimum-expected-tests 0 still fails for each module if there are zero tests run. It seems like --minimum-expected-tests 0 should have the same outcome as --ignore-exit-code 8.
Extending from that, a parameter such as --minimum-expected-tests-for-all-test-modules n might be a way to support the requested behavior.
This is now implemented end-to-end across both repos and can be closed. 🎉
Design
The feature is split into a per-module signal (owned by MTP / testfx) and a whole-run aggregation (owned by the dotnet test orchestrator in dotnet/sdk). The two levels are addressed with the standard dotnet test argument split:
Arguments before-- are global / whole-run (interpreted by the dotnet test orchestrator).
Arguments after-- are local / per-module (forwarded to each test module).
So you can express both levels independently, e.g.:
dotnet test --minimum-expected-tests 5 -- --minimum-expected-tests 2
= "at least 5 tests across the whole run" and "at least 2 tests in each module".
How the two levels stay distinguishable
The key enabler was making an explicit --minimum-expected-tests Ngovern the count-based verdict so it no longer collapses into the generic "zero tests ran" code:
An empty module (matched nothing under a --filter / --test-modules) exits with 8 (ZeroTests).
A module given an explicit per-module minimum it didn't meet exits with 9 (MinimumExpectedTestsPolicyViolation).
Because those are now separate exit codes, the orchestrator can:
normalize a per-module 8 → success before aggregating (one empty module no longer poisons the whole-run exit code, and no longer renders the run as failed in the summary while exiting 0),
decide the "zero tests ran" verdict once from the whole-run total,
still surface a stricter per-module 9 forwarded via -- --minimum-expected-tests N without swallowing it,
honor a global --minimum-expected-tests N against the aggregate total.
The empty module still keeps its Exit code: 8 diagnostic line for visibility; it just isn't counted as a run failure.
Shipped in
Side
PR
testfx (per-module signal: explicit min governs verdict, 8 vs 9)
--minimum-expected-tests 0 as an alias for --ignore-exit-code 8 was intentionally not added: allowing an explicit 0 created an ambiguity between "unset" and "explicitly 0" and a UX divergence in the terminal summary. Suppressing the zero-tests code entirely is already served by the existing --ignore-exit-code 8, and the whole-run behavior above covers the real motivation.
Availability note: the whole-run aggregation ships in the .NET 11 SDK (11.0.1xx) (dotnet/sdk#55362 merged for 11.0-preview7). It is not available in the .NET 10 SDK or earlier — the testfx per-module signal (#9709) is present, but the orchestrator that turns it into a whole-run verdict is .NET 11 SDK only for now.
Activity
nohwnd commentedon Mar 17, 2026
Missing this a lot in vstest, for running specific integration tests.
Do not fail dotnet test run when an individual test module ran zero t…
Decide dotnet test zero-tests verdict at the whole-run level (microso…
Let explicit --minimum-expected-tests govern the zero-tests verdict (#…
Allow --minimum-expected-tests 0 (#7457) (#9724)
Revert '--minimum-expected-tests 0' support (#7457)
Revert '--minimum-expected-tests 0' support (#7457)
Let explicit --minimum-expected-tests govern the zero-tests verdict (#…
Fix RunMultipleTestProjectsWithDifferentFailures expected exit code
Do not fail dotnet test run when an individual test module ran zero t…
Decide dotnet test zero-tests verdict at the whole-run level (microso…
Fix RunMultipleTestProjectsWithDifferentFailures expected exit code
Evangelink commentedon Jul 24, 2026
This is now implemented end-to-end across both repos and can be closed. 🎉
Design
The feature is split into a per-module signal (owned by MTP / testfx) and a whole-run aggregation (owned by the
dotnet testorchestrator in dotnet/sdk). The two levels are addressed with the standarddotnet testargument split:--are global / whole-run (interpreted by thedotnet testorchestrator).--are local / per-module (forwarded to each test module).So you can express both levels independently, e.g.:
= "at least 5 tests across the whole run" and "at least 2 tests in each module".
How the two levels stay distinguishable
The key enabler was making an explicit
--minimum-expected-tests Ngovern the count-based verdict so it no longer collapses into the generic "zero tests ran" code:--filter/--test-modules) exits with8(ZeroTests).9(MinimumExpectedTestsPolicyViolation).Because those are now separate exit codes, the orchestrator can:
8→ success before aggregating (one empty module no longer poisons the whole-run exit code, and no longer renders the run as failed in the summary while exiting0),9forwarded via-- --minimum-expected-tests Nwithout swallowing it,--minimum-expected-tests Nagainst the aggregate total.The empty module still keeps its
Exit code: 8diagnostic line for visibility; it just isn't counted as a run failure.Shipped in
8vs9)Note on the original item #2
--minimum-expected-tests 0as an alias for--ignore-exit-code 8was intentionally not added: allowing an explicit0created an ambiguity between "unset" and "explicitly 0" and a UX divergence in the terminal summary. Suppressing the zero-tests code entirely is already served by the existing--ignore-exit-code 8, and the whole-run behavior above covers the real motivation.Closing as fixed.
Evangelink commentedon Jul 24, 2026
Availability note: the whole-run aggregation ships in the .NET 11 SDK (11.0.1xx) (dotnet/sdk#55362 merged for 11.0-preview7). It is not available in the .NET 10 SDK or earlier — the testfx per-module signal (#9709) is present, but the orchestrator that turns it into a whole-run verdict is .NET 11 SDK only for now.
Learn docs tracked in dotnet/docs#55011.