While working with my tech lead, I saw he was using Nunit with VS2008. He was running tests same time he was also debugging the code. When I discussed the same with my colleague, he told me to how to integrate Nunit with Visual Studio 2008. Today I found another way to do this; but it wasn’t support debugging, but it wasn’t not depend on the project, instead it will act like a option in Visual Studio.
- The first way is starting the NUnit as an external program, and passing the assembly as the command line argument to NUnit. This can be achieved by Project Properties > selecting the Debug Tab > Select the “Start an external program” option from the Start Action section; instead of the Start project (default) option. And select the NUnit executable. (In my machine it is C:\Program Files\NUnit 2.5.7\bin\net-2.0\nunit.exe). Next enter the assembly file name in the Command line arguments textbox in the Start Options section. That’s it. We can run unit tests as well as we can debug the code, while running the unit tests.
- The second option is using External Tools option in Visual Studio. Select Tools > External Tools > Add
Command: (path to nunit.exe)
Initial directory: $(ProjectDir)
Click Apply, then OK. Then it will display as a menu item in the Tools menu. This will open the current project in NUnit.
We achieve the same using various plugins like ReSharper and Test Driven .Net.