【发布时间】:2013-05-21 10:33:39
【问题描述】:
我的 webdriver 测试使用 @Test(timeout = 10000) 进行注释,以强制测试在 10000 毫秒后结束。如果出现错误,这可以防止我的测试整夜挂起。
但是,我的测试也在将附加信息写入文件,如果测试以这种方式超时,则该行不会写入文件。是否有可能捕捉到这种类型的超时?
@Test(timeout = 100000)
public void testSomething() throws Exception
{
//Do some stuff
//If this times out, the line below is never called.
//print something to a file
}
【问题讨论】:
-
我不确定我是否准确理解您的需求。您能否保存文件所需的数据并在
@After中打印出来(始终执行)? -
打印到文件部分正在为每个方法写一行。如果该方法未完成,则该行将丢失。我想在抛出此超时时编写某种形式的错误,所以我认为
@After在这里不正确?
标签: java selenium junit webdriver