Wednesday, April 28, 2010

Attach debugger to NUnit GUI test runner

Here are the steps to attach Visual Studio debugger to the NUnit GUI test runner process. Attaching the debugger will allow you set breakpoints and debug NUnit test code in Visual Studio IDE.
  • Right click the Project in the solution explorer
  • Select “Start external program”
  • Right click the Project in the solution explorer
  • Click properties
  • Click the ellipses “…” button
  • Find and select the NUnit GUI test runner “c:\yourpath\nunit-x86.exe”
  • Type the name of your test dll in the “Command line arguments: “ textbox
  • Run the project and if its configured correctly the NUnit GUI runner should appear with the test dll loaded
You can also install TestDriven.NET and it packaged with NUnit and NCover, it provides right click test run and other cool stuff but can be buggy sometimes.
    I wrote this because today I ran across someone who decided to rewrite there test suite in MSTest because they couldnt debug or use break points with NUnit...  By the way, friend don't let friends use MSTest for functional tests. More than once I have run across developers or testers who didn't know how to do attach the debugger and its very simple. Perhaps the funniest occasion was on a 3 month contract with eTouch, the developers there created a separate command line (exe) project that executed the NUnit test runner passing in there dll.

    To get the Break points & Edit and Continue to work in .NET 4.0 you need to edit the nunit-x68.config file (or witch ever config of the exe your using to execute the tests)
    <startup>
        <requiredRuntime version="4.0.30319" />
    </startup>