Unit Tests not discovered in Visual Studio 2017

unit testingvisual-studio-2017

I have been struggling with VS 2017 since I installed it. Now it seems Unit Tests will only run from the command line "dotnet test."

My project is .NET Core 1.1.1. I have the SDK and the framework update for 1.1.1 installed.

I have tried the sample at MSDN (https://msdn.microsoft.com/en-us/library/ms182532.aspx) which also fails exactly the same way.

All NuGet packages for the tests and the main project are current. And both the test project and the main project build without errors. An the tests run successfully from the command line.

Has anyone gotten Unit Tests to run in VS 2017, if so how?

Thanks,
John


Update – Extend

Here is an example of a simple test project that is not working on GitHub. This is an example with xUnit but I have tried NUnit and visual studio built in MS tests. No matter what testing or what changes I make I cannot get the VS test runner to find any tests.

What I've Tried

  • Deleting VS test cache files DEL %TEMP%\VisualStudioTestExplorerExtensions
  • Restarting VS
  • Closing/Opening test explorer
  • for xUnit installed Microsoft.DotNet.InternalAbstractions (see SO post)
  • for NUnit ensure adapter installed and same version (3) as NUnit package
  • test -> test settings -> default processor architecture is set to x86

The Question
Can anyone please provide a working example of a .Net Core 1.1.0 solution in VS2017 (.csproj project files) where the VS test explorer successfully finds the unit tests OR show me the issue in the example given.

Best Answer

In my case, it turned out that I simply had to upgrade my test adapters and test framework. Done.

Example using the NuGet Package Manager:

enter image description here