eclipse JUnit 测试挂起
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/16103071/
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 test hangs
提问by Max Ni
I have the following problem: one of my JUnit tests gets stuck in eclipse doing nothing, but the blue arrow indicating that this test is currently running persists.
我有以下问题:我的一个 JUnit 测试卡在 eclipse 中,什么也不做,但表示此测试当前正在运行的蓝色箭头仍然存在。
There definitely isn't any infinite loop in my code, and everything in the tested method that gets stuck is in the following for
loop:
我的代码中绝对没有任何无限循环,并且被测试方法中卡住的所有内容都在以下for
循环中:
for (int i = 0; i < this.length(); i += 3) {
// do some stuff
}
Also, when debugging, the method properly terminates and does not let me step any more.
此外,在调试时,该方法会正确终止,并且不会再让我踩踏。
In the setUp()
I am initializing my fields and the class under test.
在setUp()
我正在初始化我的字段和被测类。
This seems like some weird JUnit/Eclipse bug. I am running Eclipse 3.7.2 and JUnit 4 under Ubuntu 12.04 using oracle-java-7.
这似乎是一些奇怪的 JUnit/Eclipse 错误。我在 Ubuntu 12.04 下使用 oracle-java-7 运行 Eclipse 3.7.2 和 JUnit 4。
Any tips how to troubleshoot this problem?
任何提示如何解决此问题?
回答by Deepak Bala
If the test is still running, you can look at the active threads in the debug
tab and suspend them by pressing the pause button. That will tell you where the test is stuck.
如果测试仍在运行,您可以查看debug
选项卡中的活动线程并按暂停按钮暂停它们。这会告诉你测试卡在哪里。