64

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?

Eric Pohl
  • 2,324
  • 1
  • 21
  • 31
Lorentz Vedeler
  • 5,101
  • 2
  • 29
  • 40

4 Answers4

88

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

Eric Pohl
  • 2,324
  • 1
  • 21
  • 31
Lorentz Vedeler
  • 5,101
  • 2
  • 29
  • 40
  • 1
    Be sure to count the tests that are discovered and executed before and then after making this change. The MsTest2 nuget packages mentioned above have experienced silent failures while discovering tests but still reporting that 100% of tests that were found have passed. – StingyJack Sep 18 '18 at 12:38
  • 1
    What do you mean "Select my unit test project(s)" How do I select something in a command line? – Joel Roberts Jul 30 '19 at 04:43
  • 1
    @joelroberts in the visual studio package manager console there is a dropdown to select which projects you want to install the packages to. – Lorentz Vedeler Jul 30 '19 at 07:03
  • I'm using NUnit, so Installing NUnit3TestAdapter worked for me. – David Klempfner May 14 '21 at 03:02
  • 1
    If you are migrating from the Microsoft.VisualStudio.QualityTools.UnitTestFramework DLL, Visual Studio (version 2017) requires a restart before tests will run successfully (after installing the mentioned packages). – Daniel Sep 19 '22 at 11:14
7

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)

DragonSpit
  • 458
  • 4
  • 9
1

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).

Ekus
  • 1,679
  • 21
  • 17
0

I use nunit, i have project from 2012. I installed NUnit3TestAdapter as suggested but it didnt help. Turned out my nuit vesion 2.6.1 was too old even for NUnit3TestAdapter which job is to work with version 3 nunit. So i selected in nuget terminal my project with tests, ran "Install-Package nunit", it updated NUnit.2.6.1 up to NUnit.3.13.3 and tests now can run.