0
votes

I am running vs.net 2008 with nunit runner.

If I set a breakpoint in the unit test code, it just runs the unit test in the runner.

I'm guessing I have to integrate nunit with vs.net somehow?

My unit tests are just a class library project, I cannot run the tests in vs.net 2008, I can only do it via the runner currently.

3
I posted a simliar question not too long ago, maybe it will be helpful (Mr Skeet got me on the right track) stackoverflow.com/questions/9130763/…SwDevMan81

3 Answers

3
votes

If you want to debug in your current setup (running nunit runner that has your assemblies loaded), do the following:

  1. Run nunit.exe
  2. Open (or create) your nunit project (File > New/Open Project
  3. Under Tools > Settings, click IDE Support > Visual Studio and check 'Enable Visual Studio Support'
  4. Once your nunit file is setup and you are ready to run, go to VS and click Tools > Attach To Process...
  5. Verify that 'Managed Code' is selected in the 'Attach to' area
  6. Find unit.exe, select it, and click Attach
  7. Place desired breakpoints in the library
  8. From the nunit GUI, click Run
  9. If youre debugging the correct assemblies, it should hit your breakpoint.

Ideally, I would change it to run nunit as an external program and supply your .nunit project file as the input. See here for more details.

1
votes

I am running vs.net 2008 with nunit runner.

If I set a breakpoint in the unit test code, it just runs the unit test in the runner.

(emphasis mine)

You just answered your own question. Why would you expect the Visual Studio breakpoint to magically push you into Visual Studio when you don't run the code via Visual Studio in the first place?

I would recommend refactoring your tests so that as many tests as possible can be run through Visual Studio (see http://www.nunit.org/index.php?p=vsSupport&r=2.2.10 for details on NUnit support for Visual Studio), and then only run the remaining tests on the console.

1
votes

To gain debugging unit tests with VS 2008, do the following:

1) Create project in NUnit runner and add your dll with unit tests into it.
2) Set up "Start external program" in your unit test project - NUnit exe file.
3) When you debug set up your unit tests project as "startup project" or whatever you have in VS2008.
4) Run