【问题标题】:webdriver, catching @Test(timeout = 10000)webdriver,捕捉@Test(超时= 10000)
【发布时间】: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


【解决方案1】:

我建议实施JUnit Rule
只需扩展 TestWatcher 类并覆盖 succeeded 方法。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-07-07
    • 2011-08-04
    • 1970-01-01
    • 2013-12-13
    相关资源
    最近更新 更多