mirror of
https://github.com/vale981/ray
synced 2025-03-05 10:01:43 -05:00
[Java] Enable retry in TestNG (#11065)
* Enable retry in Java test * lint * update
This commit is contained in:
parent
27e1f513e3
commit
79c6a6fa02
3 changed files with 35 additions and 0 deletions
|
@ -0,0 +1,15 @@
|
|||
package io.ray.test;
|
||||
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.Method;
|
||||
import org.testng.IAnnotationTransformer;
|
||||
import org.testng.annotations.ITestAnnotation;
|
||||
|
||||
public class AnnotationTransformer implements IAnnotationTransformer {
|
||||
|
||||
@Override
|
||||
public void transform(ITestAnnotation annotation, Class testClass,
|
||||
Constructor testConstructor, Method testMethod) {
|
||||
annotation.setRetryAnalyzer(RetryAnalyzer.class);
|
||||
}
|
||||
}
|
19
java/test/src/main/java/io/ray/test/RetryAnalyzer.java
Normal file
19
java/test/src/main/java/io/ray/test/RetryAnalyzer.java
Normal file
|
@ -0,0 +1,19 @@
|
|||
package io.ray.test;
|
||||
|
||||
import org.testng.IRetryAnalyzer;
|
||||
import org.testng.ITestResult;
|
||||
|
||||
public class RetryAnalyzer implements IRetryAnalyzer {
|
||||
|
||||
private int counter = 0;
|
||||
private static final int RETRY_LIMIT = 2;
|
||||
|
||||
@Override
|
||||
public boolean retry(ITestResult result) {
|
||||
if (counter < RETRY_LIMIT) {
|
||||
counter++;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
|
@ -10,5 +10,6 @@
|
|||
<listeners>
|
||||
<listener class-name="io.ray.test.RayAlterSuiteListener" />
|
||||
<listener class-name="io.ray.test.TestProgressListener" />
|
||||
<listener class-name="io.ray.test.AnnotationTransformer" />
|
||||
</listeners>
|
||||
</suite>
|
||||
|
|
Loading…
Add table
Reference in a new issue