This post originated from an RSS feed registered with .NET Buzz
by Roy Osherove.
Original Post: Debugging Unit tests using the VS.net debugger
Feed Title: ISerializable
Feed URL: http://www.asp.net/err404.htm?aspxerrorpath=/rosherove/Rss.aspx
Feed Description: Roy Osherove's persistent thoughts
Here's a very easy way to debug your unit tests line by line using the vs.net debugger (you shouldn't need to do this too often if you're doing Test Driven Development correctly though):
Set the testing project as the startup project in the solution(so you can start debug with F5)
Open the project properties of the project with all the tests
In the Configuration Properties->Debugging , set the "start action" to "start external program" and select the Nunit-gui.exe or the Nunit-console.exe
If you selected the console program, put the name of your assembly in the parameters to send to this program
That's it. Now, to start debugging:
Place a breakpoint anywhere in the code that will be tested (either a test or a code that is used by the test)
Hit F5.
If you chose to debug using the Nunit gui application, just hit "run" on the tests you want and let the debugger stop at the breakpoint you want.If you are debugging by starting the console application you will get to that breakpoint automatically eventually (all the tests in the assembly will be run).