注释类型测试的超时参数 [英] timeout parameter for Annotation Type Test
问题描述
我正在尝试在IntelliJ IDEA项目的单元测试中将超时参数用于注释类型测试:
I'm trying to use the timeout parameter for Annotation Type Test in a unit test within an IntelliJ IDEA project:
第二个可选参数timeout如果导致测试失败,则会导致测试失败 花费的时间超过指定的时钟时间(以 毫秒).以下测试失败:
The second optional parameter, timeout, causes a test to fail if it takes longer than a specified amount of clock time (measured in milliseconds). The following test fails:
@Test(timeout=100) public void infinity() {
while(true);
}
---来自 http://junit.sourceforge.net/javadoc/org/junit/Test.html
当我尝试使用它时,我从IDEA收到无法解析方法'超时'"错误.我正在使用JUnit的4.8.2版本和IDEA的10.5版本.
When I try to use this, I get a "Cannot resolve method ‘timeout’" error from IDEA. I'm using Version 4.8.2 of JUnit and version 10.5 of IDEA.
你知道我在做什么错吗?
Any idea what I'm doing wrong here?
推荐答案
最有可能在项目类路径中有多个junit.jar版本,没有此注释方法支持的旧版本会首先加载,并且会出现错误.确保在类路径中只有一个junit.jar实例,并且它是最新版本(尝试与IDEA捆绑在一起的实例).
Most likely you have multiple junit.jar versions in your project classpath, the old one without this annotation method support is loaded first and you get the error. Make sure that you have only one junit.jar instance in the classpath and that it is the latest version (try the one bundled with IDEA).
这篇关于注释类型测试的超时参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!