dotnet test "1 test files matched but 0 tests ran" in CI
This means the test assembly was found and loaded, but zero tests were discovered inside it. Unlike a filter miss, no filter is involved - the adapter saw the DLL but found nothing it recognizes as a test, usually a missing or mismatched test SDK/adapter package.
What this error means
The run prints "A total of 1 test files matched the specified pattern but 0 tests ran" and exits. It is deterministic for the project setup.
A total of 1 test files matched the specified pattern but 0 tests ran in
/work/Tests/bin/Release/net8.0/Tests.dllCommon causes
Missing test SDK or adapter package
The project lacks Microsoft.NET.Test.Sdk or the framework adapter (xunit.runner.visualstudio, NUnit3TestAdapter), so discovery finds no tests.
Wrong assembly built or framework mismatch
CI ran the wrong DLL, or the test framework version does not match the adapter, leaving discovery empty.
How to fix it
Add the test SDK and adapter
- Ensure the test project references
Microsoft.NET.Test.Sdkand the matching runner adapter. - Confirm the built assembly is the actual test project, not a library.
- Rebuild and re-run.
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.11.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.2" />
</ItemGroup>How to prevent it
- Keep test SDK and adapter packages aligned with the test framework version.
- Verify new test projects discover tests locally before wiring them into CI.