Skip to content
Latchkey

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.

dotnet
A total of 1 test files matched the specified pattern but 0 tests ran in
/work/Tests/bin/Release/net8.0/Tests.dll

Common 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

  1. Ensure the test project references Microsoft.NET.Test.Sdk and the matching runner adapter.
  2. Confirm the built assembly is the actual test project, not a library.
  3. Rebuild and re-run.
csproj
<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.

Frequently asked questions

What causes ""... matched the specified pattern but 0 tests ran""?
The project lacks Microsoft.NET.Test.Sdk or the framework adapter (xunit.runner.visualstudio, NUnit3TestAdapter), so discovery finds no tests.
How do I fix "... matched the specified pattern but 0 tests ran"?
Add the test SDK and adapter

Related guides

References

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