Hey!
I am looking for some generic way of retrying failed data providers.
I use data providers to generate some data in the cloud. Sometimes, some HTTP calls fail, and I would need to retry this data creation - I don't care too much about them falling from time to time - it's not the purpose of my tests to check the HTTP calls results.
I've checked IDataProviderListener, but the onDataProviderFailure method will anyway cause an exception to be thrown in org/testng/internal/Parameters.java:803
It would be nice to have a data provider method implementing e.g. IConfigurable so that it is possible to check if there is a throwable thrown from an execution of a dataprovider, and then implement some retry logic invoking failed dataprovider, just like I did it for configuration methods:
```public class RetryConfigurationMethodsListener implements IConfigurable, IHookable {
@Override
public void run(
IConfigureCallBack callBack,
ITestResult testResult) {
callBack.runConfigurationMethod(testResult);
if (testResult.getThrowable() != null) {
String className = testResult.getMethod().getTestClass().getName();
String methodName = testResult.getMethod().getMethodName();
System.
out.println(
String.
format("Configuration method '%s#%s' failed. Retrying...", className, methodName));
for (int i = 0; i < 3; i++) {
sleep5s();
callBack.runConfigurationMethod(testResult);
if (testResult.getThrowable() == null) {
break;
} else {
System.
out.println(
String.
format("Retry %d/%d of '%s#%s' method failed.", i + 1, 3, className, methodName));
}
}
}
}
}```