JUnit 不会在 Eclipse 中的断点处停止(使用 JDK 1.6.0.20)
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2744351/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
JUnit won't stop at breakpoints in Eclipse (using JDK 1.6.0.20)
提问by Bozho
my breakpoints in Eclipse won't stop the execution of a JUnit test. It doesn't matter where I set the breakpoint in the JUnit method, it simply won't stop the code from flowing. Placing it in a class called in the JUnit test won't work either.
我在 Eclipse 中的断点不会停止 JUnit 测试的执行。我在 JUnit 方法中设置断点的位置无关紧要,它根本不会阻止代码流动。将它放在 JUnit 测试中调用的类中也不起作用。
I am using the JDK in the version of 1.6.0.20, so I guess I'm not affected by the bug in version 1.6.0.14.
我使用的是1.6.0.20版本的JDK,所以我想我没有受到1.6.0.14版本的bug的影响。
Do you know any hints concerning this matter?
你知道关于这件事的任何提示吗?
回答by Bozho
You should start your unit-tests with Debug as > JUnit test
你应该开始你的单元测试 Debug as > JUnit test
回答by Matthias Ronge
If your break points appear with a back slash across, you have to go to the debug perspective (Window → Open perspective) and in the ‘Breakpoints' window, unselect the ‘Skip all break points' button (circle with backslash across)
如果断点出现反斜杠,则必须转到调试透视图(窗口→打开透视图)并在“断点”窗口中取消选择“跳过所有断点”按钮(带反斜杠的圆圈)
回答by Rohit Sachan
Plese use
请使用
-XX:+UseParallelGC
in debug configuration > VM arguments section
在调试配置> VM 参数部分
回答by Bowi
I've had this problem today and for me the reason was pure stupidity – if the unit test outputs something to the console at first and throws an exception afterwards, both before reaching the breakpoint, you do not see the exception in eclipse's debug perspective because it gets printed in the JUnit view, but the output before switched away from that view to the Console output.
我今天遇到了这个问题,对我来说,原因是纯粹的愚蠢——如果单元测试首先向控制台输出一些东西,然后在到达断点之前抛出异常,你在 eclipse 的调试透视图中看不到异常,因为它在 JUnit 视图中打印,但之前的输出从该视图切换到控制台输出。
回答by Philip Rego
There's likely an error in your test which is preventing JUnit from getting to the thing you're trying to test. JUnit doesn't like to show these errors. Try removing lines from your unit tests until they start to work, or put breakpoints inside the methods your unit test is calling.
您的测试中可能存在错误,导致 JUnit 无法访问您要测试的内容。JUnit 不喜欢显示这些错误。尝试从单元测试中删除行,直到它们开始工作,或者在单元测试调用的方法中放置断点。