mirror of
https://github.com/wassname/ray.git
synced 2026-06-27 20:22:39 +08:00
[Java] Enable retry in TestNG (#11065)
* Enable retry in Java test * lint * update
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user