"dotnet test: No test is available" in CI
VSTest ran but discovered zero tests because the project is missing the discovery/execution plumbing - typically the Microsoft.NET.Test.Sdk package and a framework adapter (xUnit/NUnit/MSTest). Without these, there is nothing to register and no tests are found.
What this error means
The dotnet test step warns "No test is available" and tells you to ensure test discoverers and executors are registered. The run "passes" with zero tests, which can silently hide a broken suite.
No test is available in /repo/bin/Debug/net8.0/Tests.dll. Make sure that test discoverer
& executors are registered and platform & framework version settings are appropriate.Common causes
Missing Microsoft.NET.Test.Sdk
Without the test SDK package, the project does not produce a testable assembly with the VSTest entry point.
Missing the framework test adapter
The xUnit/NUnit/MSTest adapter package is absent, so the discoverer for that framework is not registered.
How to fix it
Add the test SDK and adapter packages
- Reference
Microsoft.NET.Test.Sdkplus your framework's adapter and core packages. - Restore and re-run
dotnet test.
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.11.1" />
<PackageReference Include="xunit" Version="2.9.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.2" />
</ItemGroup>Test the right assembly/TFM
- Point
dotnet testat the test project/solution, not a library. - Ensure the test project's TFM matches the installed runtime.
- Re-run.
How to prevent it
- Keep
Microsoft.NET.Test.Sdkand an adapter in every test project. - Fail CI when the discovered test count is zero to avoid silent passes.
- Restore before test so the adapters are present.