Overview: This article talks about using the NUnit Test Adapter to integrate the NUnit test runner with the Visual Studio Test Explorer. In particular, we need to ensure that we're using the right Test Adapter package for the version of NUnit that we're using.
I like using the Visual Studio Test Explorer. This is integrated into my environment, and I can always undock the window and move it to a different monitor. In particular, I love this button:
This is the "Run Tests After Build" button (it's currently only available in the expensive version of Visual Studio). When this button is toggled down, impacted unit tests are automatically run every time I build. This gives me immediate feedback when I break something.
Integrating NUnit with the Test Adapter
I've started using NUnit more and more (check out the "Why NUnit?" articles here: http://www.jeremybytes.com/Demos.aspx#UTMMF). In addition to the NUnit framework, there is also a Test Adapter package available from NuGet that integrates the NUnit test runner with the Visual Studio test explorer.
I've been using this functionality for quite some time now: Integrating NUnit into Visual Studio Test Explorer.
The problem is that we've had a bit of a version mis-match between NUnit and the Test Adapter since NUnit 3 came out last November. The good news is that last week (April 19th, 2016), the Test Adapter that's compatible with NUnit 3 finally hit release.
NUnit Version 3 and the NUnit3TestAdapter
To use NUnit and the Test Adapter with a particular project in Visual Studio, we just need to use NuGet to grab the appropriate packages. But we need to pay attention to the packages that we're pulling.
For NUnit 3, we want the following 2 packages:
Since we're using Nunit version 3 (specifically v3.2.1), we need to use the "NUnit3TestAdapter" package.
Note: This is a completely different package from the old test adapter. It is not merely the old package with a new version.
NUnit Version 2 and the NUnitTestAdapter
If you're still using NUnit version 2, we need to use a completely different test adapter package:
Here, we have NUnit version 2 (specifically v2.6.4), so we need to use the "NUnitTestAdapter" package.
Note: This is a different package from the new test adapter.
The moral of the story is that we need to be careful about the packages that we pull down when using NUnit.
When using NUnit 3, we need to use the NUnit3TestAdapter package.
When using NUnit 2, we need to use the NUnitTestAdapter package.
Even though the NUnit framework packages are the same (with different versions), the test adapter packages are different packages. If we get a mismatch, then we won't see our tests in the test explorer.
But when we get the right packages together, things work great. We get to see our tests inside Visual Studio, and we can interact with them easily in the integrated environment.