Visual Studio 2010 Test View doesn't find 2nd NUnit test project

471 views Asked by At

I can see both test projects from the NUnit Gui (loaded separately) but I can not see both projects from the Visual Studio Test View. The Test View only shows the first/original project. Hitting reload doesn't do anything. How do I get the Test View to display the second/later project? It should show both at the same time/same view, yes?

If I can only see one project's test in the Test View by design, how do I get the Test View to change projects?

Details:

I created the second project by hand ie not "create a test" as a project library with the nunit.framework.dll referenced. I checked the assembly files of the two projects as well as the properties and they look the same.

I'm on VS 2010 Professional using NUnit 2.6.0.12051 with "Visual NUnit 2010" version 1.2.4 extension installed.

I have one NUnit test project that is working both in VS Test View and NUnit Gui. I added a second project with a [TestFixture] class and a [Test] method. All projects build sucessfully. Both tests refer to the nunit.framework.dll in a parent directory to both.

2

There are 2 answers

0
kdbanman On

There are many problems that can cause this. Here's what mine was:

  • I had 2 NUnit test projects.
  • "Test Explorer" -> "Run All" would only find tests from one project.
  • Explicitly right clicking on one of the tests that wasn't found and clicking "Run Test" resulted in "No tests found." in the Output window.
  • All projects on all configurations were set to Any CPU, but it didn't matter if X86 was chosen for everything either.

The problem was that my Visual Studio (2015, FWIW) was using Test Adapter 2.x, and one of my projects had pulled NUnit 3.0 using NuGet. Test Adapter 2.x doesn't run NUnit 3 tests, so my NUnit 3 test project was being ignored.

To solve the problem:

  1. Uninstall all NUnit Test Adapters (from Visual Studio -> Tools -> Extensions and Updates and from each project's NuGet Package Manager window).
  2. Update all test projects to NUnit 3.0 using each project's NuGet Package Manager Window.
  3. Install the NUnit3 Test Adapter from Visual Studio -> Tools -> Extensions and Updates

Notes:

  • If you need to stick to NUnit 2, then just install the appropriate Test Adapter. The important thing is consistency.
  • If you were using test adapters installed by NuGet before, but switched to a Visual Studio Extension, then you may have problems loading resources/files from path strings. See this answer to solve that issue.
0
Bill D On

There is a tag in the project file describing a project as a test project.

In the PropertyGroup section of the csprj file, add this:

<ProjectTypeGuids>{3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>

See more details here: http://www.kindblad.com/2010/08/07/how-to-change-an-existing-visual-studio-project-into-a-test-project