Why will Visual Studio 2019 will not run my unit tests?

I stumbled upon the same problem. It seems to me that I have to install more and more with each release. In my case (Visual Studio 2019 community edition, version 16.6.1), I now also had to obtain the Microsoft.NET.Test.Sdk via NuGet.

So in the end, I have installed three packages in my test project:

  • NUnit (3.12.0)
  • NUnit3TestAdapter (3.17.0)
  • Microsoft.NET.Test.Sdk (16.7.1)

Turning the automated test discovery on or off did not change anything for me though.

Hope this helps anyone.


The solution turned out to be a combination of two things.

  1. On the top menu, navigating to Test > Options and disabling "Discover tests in real time from C# and Visual Basic .NET source files". This option appears to be incompatible with parameterized tests. The problem is that parameterized tests do not "exist" in source code but are generated by the test adapter at runtime. This also fixed an issue I've seen where the "base" test of the parameterized test shows up in the Test Explorer as a not-run test, even though only the specific test cases are real tests. (In my opinion, this should not be enabled by default because parameterized tests are extremely useful, whereas seeing new tests in the Test Explorer without compiling is a trivial convenience since you must compile to run them anyway.)

  2. Using the NuGet package for the test adapter instead of using the VSIX extension. It seems that for this piece, all that is required is that at least one project in your solution references this. If at least one project references it, all test projects can be run. (This makes sense to me, as it is more compatible with build tools outside of Visual Studio.)

Hooray for breaking changes!