Running and debugging NUnit tests through Visual Studio

June 18, 2009

Getting 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:

  1. Right-click on your tests project and open up the Properties window
  2. In the Debug section, under Start Action, select “Start externam program” and specify the path to your nunit.exe (save & close)
    image
  3. Right-click on your tests project and select “Set as StartUp project” if it isn’t already.
  4. 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!

blog comments powered by Disqus

About me

I'm a consultant with Headspring in Austin, TX. My passion is creating web-based applications that are well crafted and solve real problems for real people. Want to know more? Check out my about page.

WTF is all this code? I came here for food!

My wife made a new year's resolution to try out at least one new recipe each week. Want to know what she's been feeding me? resolutionfood.blogspot.com