[英]Testng rerun ignored tests
I want to rerun failed tests using testng, so I have the following testng.xml:我想使用 testng 重新运行失败的测试,所以我有以下 testng.xml:
<!DOCTYPE suite SYSTEM "https://testng.org/testng-1.0.dtd">
<suite name="suit1" configfailurepolicy="continue">
<listeners>
<listener class-name="PackageName.AnnotationTransformer"/>
</listeners>
<test name="all-tests">
<packages>
<package name="PackageName"/>
</packages>
</test>
</suite>
Annotation transformer class:注解变压器class:
public class AnnotationTransformer implements IAnnotationTransformer {
@Override
public void transform(ITestAnnotation annotation, Class testClass, Constructor testConstructor, Method testMethod) {
annotation.setRetryAnalyzer(MyRetryAnalyzer.class);
}
}
The problem is testng runs the following test even though it has Ignore annotation:问题是 testng 运行以下测试,即使它具有忽略注释:
@Test
@Ignore
public void testRetry() {
System.out.println("enter here");
}
RetryAnalyzer class:重试分析器 class:
public class MyRetryAnalyzer implements IRetryAnalyzer {
private int retryCount = 1;
private static final int maxRetryCount = 1;
@Override
public boolean retry(ITestResult iTestResult) {
if(retryCount <= maxRetryCount) {
System.out.println("retry test "+iTestResult.getName());
retryCount++;
return true;
}
else {
return false;
}
}
}
Why testng runs the ignored tests?为什么 testng 运行忽略的测试?
@Ignore should be on class or package and not on method @Ignore应该在 class 或 package 上,而不是在方法上
TestNG lets you ignore all the @Test methods:
TestNG 让您忽略所有@Test 方法:
- In a class (or)
在 class(或)中
- In a particular package (or)
在特定的 package (或)
- In a package and all of its child packages
在 package 及其所有子包中
You can add @Test(enabled=false)
to method so it will be ignored您可以将
@Test(enabled=false)
添加到方法中,以便将其忽略
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.