Running Nunit post Visual Studio 2010 and .Net 4
Posted by robkraft on July 1, 2010
Prior to our upgrade to Visual Studio 2010 and .Net 4 (which also forced us to upgrade Nunit), we were able to easily launch nunit.exe from a visual studio project by setting the “Start external program” property on the debug tab to the nunit.exe. From there, we could set break points and step through our nunit tests. But after all of our upgrades, we find that setting break points and doing step through debugging is not so convenient, though certainly still possible.
For starters, we need to specify that our projects launch nunit-x86.exe instead of nunit.exe in the “Start external program” of our projects. Then you can run the project which will launch nunit-x86.exe. Before running a test, go to Visual Studio and select “Attach to Process” from the debug menu. Select the process named nunit-agent-x86.exe. Then you should be able to set your breakpoints and hit them for step through debugging.
If you find the above does not work, check the following:
1) Use task manager to kill any instances of nunit-agent-x86.exe. This can easily be left hanging in memory if you stop a test by ending the debugging session in Visual Studio rather than closing the nunit-x86.exe through its normal program close method. If nunit-agent-x86.exe is already running you are likely to see a message “System.ApplicationException” “Unable to find test in assembly”. “Assembly Not Loaded”.
2) If you are still unable to hit breakpoints, then open nunit-x86.exe and go to the Tools – Settings and select the Assembly Reload section under the Test Loader section. Make sure that only the “Reload when test assembly changes” option is checked.