Running and debugging NUnit tests through Visual Studio
June 18, 2009Getting into this whole unit testing thing? Even for a newbie, following some of the new ASP.NET MVC and tutorials built on the "Test Driven Development” philosophy has been pretty easy. It only took a few steps and I was creating and testing actual tests with NUnit.
Wait. Testing the tests?
No one even mentioned that. And boy was I making some foolish mistakes and causing exceptions the first few times around while writing my tests. But the NUnit GUI or console is a separate app that runs your test DLLs. How the heck can you debug?
It’s actually one quick & easy step in Visual Studio. Probably obvious and known to many, but I sure was perplexed at first. Here’s what you need to do:
- Right-click on your tests project and open up the Properties window
- In the Debug section, under Start Action, select “Start externam program” and specify the path to your nunit.exe (save & close)
- Right-click on your tests project and select “Set as StartUp project” if it isn’t already.
- Hit F5 and run!
Running will launch a new instance of the NUnit GUI and when you run the tests, any breakpoints will be hit and you can walk through your actual test methods in Visual Studio!
Tags: nunit, debug, visual studio
Categories: Troubleshooting, Unit Testing
