Rob Kraft's Software Development Blog

Software Development Insights

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.

Happy debugging!

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: