dotnet test "No test is available" in CI
The runner built the test assembly but the VSTest engine discovered nothing to run. "No test is available" means the test adapter (xUnit, NUnit, MSTest) is missing, or no test methods matched.
What this error means
dotnet test exits non-zero with "No test is available in <assembly>.dll. Make sure that test discoverer and executors are registered and platform and framework version settings are appropriate."
No test is available in /app/tests/bin/Release/net8.0/MyApp.Tests.dll.
Make sure that test discoverer and executors are registered and platform and
framework version settings are appropriate, and try again.Common causes
The test SDK or adapter package is missing
Without Microsoft.NET.Test.Sdk and an adapter (xunit.runner.visualstudio, NUnit3TestAdapter), VSTest cannot discover tests.
No tests matched, or the wrong assembly was run
The project has no [Fact]/[Test] methods, or test was pointed at a non-test assembly.
How to fix it
Add the test SDK and adapter
- Reference
Microsoft.NET.Test.Sdkand your framework's adapter in the test project. - Restore and rebuild the test project.
- Re-run
dotnet test.
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.11.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.2" />Target the correct test project
Point dotnet test at the project that actually contains tests, not a library or the solution's app project.
dotnet test tests/MyApp.Tests/MyApp.Tests.csprojHow to prevent it
- Keep
Microsoft.NET.Test.Sdkplus an adapter in every test project. - Run
dotnet testagainst the test project or solution explicitly. - Confirm test methods carry the framework attributes.