【发布时间】:2019-06-21 20:19:07
【问题描述】:
如果 TestNG 测试失败,我想重试一些特定于方法的代码,而不是重试整个测试。
我从这里https://github.com/haojiwu/testng-retry-example 研究了自定义测试侦听器和重试分析器。如果失败,这将重新运行整个测试我想要一些特定于方法的代码。
@Test()
public void testStuff() {
String var1;
String var2;
/* Code specific to this test and should only be ran once. */
doSomething(param1)
/* Contains code looking for files that may or not be ready by the time the code is ran. */
/* I want to try this code then wait and retry up to a max of 3 retries. */
assertStuff(var1, var2);
}
我想执行 doSomething(param1) 中的代码,如果断言失败,则尝试 assertStuff(var1, var2) 中的内容我想等待 5 秒,然后重试 assertStuff(var1, var2) 代码如果断言通过则测试通过,否则重试最多 2 次。
【问题讨论】:
-
欢迎来到stackoverflow。请添加您尝试过的代码并澄清您遇到的问题。更多信息here