Retry mechanism in karate testing framework How to retry tests on failure in karate testing framework like Junit and TestNG. something like public class Retry implements IRetryAnalyzer {
private int count = 0;
private static int maxTry = 3;
@Override
public boolean retry(ITestResult iTestResult) {
if (!iTestResult.isSuccess()) { //Check if test not succeed
if (count < maxTry) { //Check if maxtry count is reached
count++; //Increase the maxTry count by 1
iTestResult.setStatus(ITestResult.FAILURE); //Mark test as failed
return true; //Tells TestNG to re-run the test
} else {
iTestResult.setStatus(ITestResult.FAILURE); //If maxCount reached,test marked as failed
}
} else {
iTestResult.setStatus(ITestResult.SUCCESS); //If test passes, TestNG marks it as passed
}
return false;
}
}
It works for me on version 0.9.5.RC5 . But, maybe this is one of the before-mentioned "workarounds"?
All you do is something like this, which defaults to 3 attempts:
* retry until responseStatus == 404
When method get
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With