What to do if your Visual Studio Unitest stopp working?

image you have an ongoing project with many unit tests. You are working with the project for a longer time and one day you pull the latest version and UnitTests do not execute. That means all works fine, but nothing works. You run the test and see the output window of the test execution following:

========== Test run finished: 0 Tests (0 Passed, 0 Failed, 0 Skipped) run in 4 ms ==========

In the past, this issue was noticed during updates of the Visual Studio. However, this issue is mostly caused when working with git repository or any other source repository. The merge process night sometimes removes some required nuget packages. The Visual Studio unit testing framework is not a Visual Studio feature. It is implemented in several nuget packages. For example, this issue happens if for some reason the package MSTest.TestAdapter is removed from the project file.
However, this is not the only required package. To figure out which packages are required for the proper test execution, I usually create the new TestProject in the VS and grap all required packages from there and paste them directly in the project filr of the project that does not execute unit tests.

This is the correct list of required packages at the day of writing this post.

<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.1.0" />
<PackageReference Include="MSTest.TestAdapter" Version="2.2.7" />
<PackageReference Include="MSTest.TestFramework" Version="2.2.8" />
<PackageReference Include="coverlet.collector" Version="3.1.0" />

If you remove the TestAdapter package, the tests will not be executed, as described above.

Hope this helps.

comments powered by Disqus