NUnit 与 VS 2010 不再在断点处停止
这个问题的答案一定很简单,但我确实不明白。
我正在 VS2010 下开发一个 MVC2 项目,单元测试是用 NUnit 编写的。
我通过启动 NUnit GUI 来调试测试(和代码),然后单击“调试”->“调试”。附加到VS中的进程,并附加到nunit-agent。
一段时间以来,这一切都运行良好。
我为今天早上发现的一个错误添加了一项额外的测试,突然间,我的断点没有被命中。 NUnit 只是愉快地运行并表示测试通过(它不应该通过,因为我还没有修复错误),而没有在我在测试方法中的第一个可执行行上设置的断点处停止。
我已经查看了我能想到的所有内容,包括重新启动机器,但我无法弄清楚发生了什么变化。 (FWIW,测试项目配置为在 .NET 3.5 下运行,我正在运行 NUnit 2.5.4。我已将 4.0“supportedRuntime”标志和“loadFromRemoteResources”标志添加到 nunit.exe.config 部分,并且我还尝试附加到 nunit.exe 而不是 nunit-agent.exe 请注意,我没有收到带有“无法加载源代码”消息的禁用断点按钮,断点是标准的红球,它们只是永远不会得到。打。)
The answer to this has got to be simple, but I sure don't see it.
I'm working on an MVC2 project under VS2010, with Unit tests written in NUnit.
I debug the tests (and code) by starting the NUnit GUI, then clicking Debug -> Attach To Process in VS, and attaching to nunit-agent.
This has all worked fine for some time.
I added one additional test for a bug that I discovered this morning, and suddenly, my breakpoints are not being hit. NUnit just runs merrily along and says the test passes (which it shouldn't, since I haven't fixed the bug yet), without ever stopping at the breakpoint I have set on the very first executable line in the test method.
I've looked at everything I can think of, including rebooting the machine, and I can't figure out what has changed. (FWIW, the test project is configured to run under .NET 3.5, and I'm running NUnit 2.5.4. I have added the 4.0 "supportedRuntime" flag and "loadFromRemoteResources" flag to the section of nunit.exe.config, and I have also tried attaching to nunit.exe instead of nunit-agent.exe. Note that I am NOT getting the disabled breakpoint buttons with the "source code cannot be loaded" messages. The breakpoints are the standard red ball, they just never get hit.)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
答案确实很简单。
在此过程中,我一直在使用 VS2010 通过附加到浏览器来调试脚本代码。当您附加到调试器中的进程时,您必须告诉它您正在调试哪种代码,并且调试脚本代码与调试托管代码不兼容,因此它会关闭托管代码。显然 VS 会记住你最后的选择。
因此,当我尝试附加到 N-Unit 时,它选择了脚本作为我想要调试的代码类型,但我没有注意到。我所要做的就是选择“附加到进程”对话框中的下拉框,然后检查托管代码。
感谢 Paul Laudeman 在他的 CodeBetter 博客
The answer was indeed simple.
Somewhere along the line, I had been using VS2010 to debug Script code by attaching to the browser. When you attach to a process in the debugger, you have to tell it what kind of code you are debugging, and debugging script code is incompatible with debugging managed code, so it turns off Managed code. Apparently VS remembers your last selection.
So when I attempted to attach to N-Unit, it was selecting Script as the type of code that I wanted to debug, and I didn't notice. All I had to do was select the drop down box in the "Attach to process" dialog box, and check managed code.
Thanks to Paul Laudeman in his CodeBetter Blog
尝试附加到 nunit-agent.exe 进程。这对我有用。
Try attaching to the nunit-agent.exe process. That worked for me.