TA的每日心情 | 开心 2017-6-23 14:35 |
---|
签到天数: 1 天 连续签到: 1 天 [LV.1]测试小兵
|
这样写能实现失败用例重运行,但是第二条用例并没有失败也会执行2次,要怎么改才能让第二条成功的不执行两次呢?
public class retryLis implements IAnnotationTransformer {
public void transform(ITestAnnotation annotation, Class testClass,
Constructor testConstructor, Method testMethod) {
IRetryAnalyzer retry = annotation.getRetryAnalyzer();
if (retry == null) {
annotation.setRetryAnalyzer(retry.class);
}
}
}
public class retry implements IRetryAnalyzer {
private int retryCount = 0;
private int maxRetryCount = 2; // retry a failed test 2 additional times
public boolean retry(ITestResult result) {
if (retryCount <maxRetryCount) {
retryCount++;
return true;
}
return false;
}
}
public class mycase {
@DataProvider(name = "test")
public static Object[][] NoNameMethod(){
return new Object[][]{{0},{1},{2}};
}
@Test(dataProvider = "test")
public void myTestCase(int a) {
Assert.assertEquals(a,1,"出错了");
}
}
|
|