Search Wiki:

NUnit integration in Visual Studio.


This add-in for Visual Studio Team System will allow you to run NUnit tests just like Visual Studio Unit tests integrated in Visual Studio. It makes Visual Studio to see NUnit test as mstest. That means everything you can do with Visual Studio Unit tests you can also do with NUnit tests. For example publishing of results in TFS or code coverage.

How to

Visual Studio (Professional, Developer and Tester Editions) are capable of running unit tests. Unfortunatly it does not support NUnit tests. Converting NUnit tests to Visual Studio unit tests takes time and sometimes not possible. That's why this utility. It allows Visual Studio to see and run NUnit tests without changing any code.

Visual Studio "marks" all test projects with some special Guids. Thats why you have to first convert your NUnit test project to a "Test Project".
To do this open your solution. In Solution Explorer right click on a project that you want to make a test project and select "Unload Project". This will allow you to edit project csproj file. Once more right click on project and select "Edit <projectname>.csproj". This will open csproj file in editor. Now you have to add following tag in first <PropertyGroup> tag:
<ProjectTypeGuids>{3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
Now close the project file in editor saving the changes, right click on project in Solution Explorer and select "Reload Project". Now Visual Studio recognize this project as a test project and you can see and run Visual Studio unit tests.

Now go in menu Test->Windows->Test View. You should now see your NUnit tests in Test View window. Test list is being refreshed after each successful project build.



The problem with Test not being refreshed in "Test view" was finally solved with a help of Gallio project. Parts of NUnitForVS uses code from Gallio http://www.gallio.org
Last edited Jul 10 at 7:44 AM  by nesher, version 10
Comments
Also available: 1 review for current release.

jasearles wrote  Oct 10 2007 at 12:36 PM  
This doesn't seem to be working for me. The project still shows the c# icon. If I right click on the project it does show me the correct "New Item" window however. The new items it is showing are all test related.

When I go to "Test View" I don't see any tests. Could you have missed a step in your instructions?

nesher wrote  Oct 14 2007 at 6:27 PM  
If "New Item" shows Tests then you have successfuly converted your project to test project. Make sure you have created *.nunit file in this test project. It is possible that you have to reopen your solution (small bug in NUnitForVS).
If you add VS Unit test to project can you see it in Test View?

p.s.: could you please write in Discussions instead of first page.

ThomasW wrote  Apr 13 at 5:21 PM  
This is cool !! Thanx a lot

staxmanade wrote  Jun 3 at 6:28 PM  
This framework is fantastic, seamless, and easy. Being able to use the built in VS code coverage tools for our unit test and database unit test projects has helped discover some paths we never thought about. Thank you for this great solution.

hemant wrote  Aug 7 at 8:44 PM  
what is to be done to fix this error message?
Warning: Test Run deployment issue: The assembly or module 'nunit.framework' directly or indirectly referenced by deployment item 'kkkkk.dll' specified by the test 'ggggg.dll' was not found.

Updating...