我的 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
}
最佳答案
我建议实现 JUnit Rule
.
只需扩展 TestWatcher
类并重写 succeeded
方法。
关于java - webdriver,捕获@Test(超时= 10000),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16667882/