Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Retry mechanism in karate testing framework [duplicate]

Tags:

karate

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;
}

}

like image 803
Rahul R Avatar asked Nov 07 '22 09:11

Rahul R


1 Answers

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

enter image description here

like image 134
djangofan Avatar answered Dec 01 '22 20:12

djangofan