Debug your NUnit Tests in VS Express 2005

Today it was a lucky day and I found out how I can make my unit tests working in VS Express 2005.

Normally you can attach the debugger to the nunit-GUI – but not in the Express Version!

This is really annoying. So look here for the workaround.

If you are new to C# it is a little bit different as in Java to create a test case.

You can do the following

  1. Install NUnit
  2. Create a new project with your sources. E.g. call it HelloWorld. (choose Windows Application)
  3. Add a new project with your tests to the solution. E.g. call it HelloWorldTest. Right click the solution and click ‘New Project’ (choose class library)
  4. Then right click HelloWorldTest and ‘Add Reference’. Browse until you find \ProgramFiles\NUnit\bin\nunit.framework.dll
  5. Add some unit test to HelloWorldTest
  6. Apply the mentioned hack above on HelloWorldTest.csproj
  7. Right click HelloWorldTest and click ‘Specify as StartUp Project’
  8. Press F5 and you should see the NUnit-GUI running your test cases. Now you can set breakpoints and evaluate expression in the test class (like you would do in HelloWorld).