NUnit 2.5.7 requires explicit Debug Attach under VS2010

拈花ヽ惹草 提交于 2019-12-19 04:04:25

问题


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 under 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 NUnit Agent, 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.


回答1:


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>

Edit 2: I also recently found that the order of the entries also makes a difference.




回答2:


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?



来源:https://stackoverflow.com/questions/3542904/nunit-2-5-7-requires-explicit-debug-attach-under-vs2010

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!