views:

177

answers:

2

I've just "upgraded" from NUnit 2.5.2 to NUnit 2.5.7 so that I can run unit tests against an dll's built with .Net Framework 4. I've been using 2.5.2 for a long time via the "StartExternalProgram" property uner project properties. I've never had to explicitly debug attach to the NUnit process in that scenario.

Now under 2.5.7 it appears that one must explicitly attach to the NUnit_Agent process in order to debug the code under test.

Of course this means that instead of requiring two clicks to run my unit tests I now have to click Debug.Run icon in VS2010, wait for NUnit GUI to appear, alt-Tab back to VS2010, click Debug.Attach.., scroll down the list to find NUnitAgent, double click to select it, alt-Tab back to NUnit GUI, click Run to run the test(s).

So, is there a reason that using Nunit has become that much more difficult under 2.5.7 or did a ball get dropped?

Thanks in advance for any advice on restoring the "automagic attach" from earlier versions.

Bill

A: 

Perhaps not quite an answer to your problem, but a different way of looking at it: Resharper includes a component that runs nunit tests within the VS2010 gui without needing any separately configured external programs. This might simplify things for you?

Might give it a try if can't find another solution; however another option is to use VS2010's built in Test support. I prefer NUnit, but not with all the extra hoo-hah.
Bill Cohagan
A: 

The problem is that NUnit is kicking off a child process (nunit-agent.exe.) I was able to fix this by opening up nunit.exe.config and adding the following section:

<startup>
    <supportedRuntime version="v4.0.30319" />
</startup>

Edit: If you still want to use nunit with .Net 2.0, make sure to add that version as well. My config ended up looking like this:

<startup>
    <supportedRuntime version="v2.0.50727" />
    <supportedRuntime version="v4.0.30319" />
</startup>
Pedro
Tried this and no joy; i.e., breakpoint not hit. I'm using the x86 variant, but can't see how that'd make a difference. I added the <startup> element as the first subelement of the <configuration> element in the file, nunint-x86.exe.config. I'm curious as to why adding this element would avoid the launching of the agent process?
Bill Cohagan
As far as I can tell, the agent process is kicked off if you are using a different runtime than the supported one(s).
Pedro
Any idea why this isn't working for me? I notice that the agent process is *not* spun up -- so that aspect of the fix seems to work; however when I run the app and NUnit starts up, running the tests ignores any breakpoints I have set. How about settings within NUnit itself (under Tools.Settings?) I tried "Run tests directly in the NUnit process" as it seemed the obvious choice, but that didn't help. Any other ideas?
Bill Cohagan
Turning Shadow Copy on or off might change the behavior, but I'm not sure if that is causing the problem...
Pedro