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.
If you want to debug in your current setup (running nunit runner that has your assemblies loaded), do the following:
- Run nunit.exe
- Open (or create) your nunit project (File > New/Open Project
- Under Tools > Settings, click IDE Support > Visual Studio and check 'Enable Visual Studio Support'
- Once your nunit file is setup and you are ready to run, go to VS and click Tools > Attach To Process...
- Verify that 'Managed Code' is selected in the 'Attach to' area
- Find unit.exe, select it, and click Attach
- Place desired breakpoints in the library
- From the nunit GUI, click Run
- 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.
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.
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