Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why do I get a "No test adapters are referenced by this solution" error message?

When I start a Live Unit Tests session on my solution in visual studio 2017, I get the following message:

No test adapters are referenced by this solution. If you have a test project, add a NuGet reference to a test adapter corresponding to the test framework used in order to run the tests. If you already have the required NuGet reference in your test project, performing a NuGet restore may resolve the issue.

What can I do to remedy this situation?

like image 246
Lorentz Vedeler Avatar asked Mar 10 '17 08:03

Lorentz Vedeler


People also ask

What is test adapter?

Test adapter used for unit tests. This adapter can be used to simulate sending messages from the user to the bot.

What is xUnit runner Visualstudio?

xunit.runner.visualstudio. This package contains the VSTest runner. This runner is capable of running . NET Framework projects from xUnit.net v1 and v2, and . NET Core and UWP projects projects from xUnit.net v2.

Should tests be in separate project?

Automatic Integration Tests (made i NUnit) should be in a seperate project since they don't belong to any single project. But that means you cannot run tests on the Release build and few "heisenbugs" can fall through.


3 Answers

As the message implies, you need to install some NuGet packages, one for the testing framework and one for the visual studio test runner. If you are upgrading an old solution using MSTest, you first need to remove the reference to Microsoft.VisualStudio.QualityTools.UnitTestFramework.

Then you need to open the Package Manager Console (under Tools-> Nuget Package Manager -> Package Manager Console). Select your unit test project(s) and run the following commands:

Install-Package MSTest.TestFramework
Install-Package MSTest.TestAdapter

If you are using a different test framework, such as XUnit or NUnit, you have to install either XUnit and xunit.runner.visualstudio, or NUnit and NUnit3TestAdapter

like image 164
Lorentz Vedeler Avatar answered Oct 05 '22 19:10

Lorentz Vedeler


I created a brand new project in VisualStudio 2017 and was getting the same error message until I installed xunit.runner.visualstudio NuGet package. Follow these instructions on the Xunit getting started webpage (https://xunit.github.io/docs/getting-started/netfx/visual-studio)

like image 37
DragonSpit Avatar answered Oct 05 '22 20:10

DragonSpit


I was able to see the tests in Test Explorer but they were being ignored.

I found and deleted a Local.testsettings file in the solution folder and it fixed the problem (I had earlier updated the nuget packages as the other answer suggests but that was not enough in my case).

like image 31
Ekus Avatar answered Oct 05 '22 18:10

Ekus