Skip to content

Instantly share code, notes, and snippets.

@borodicht
Created November 17, 2024 17:52
Show Gist options
  • Save borodicht/82f8fbb634d2ef8b153f19d8b4cbb90c to your computer and use it in GitHub Desktop.
Save borodicht/82f8fbb634d2ef8b153f19d8b4cbb90c to your computer and use it in GitHub Desktop.
package testng;
import org.testng.IRetryAnalyzer;
import org.testng.ITestResult;
public class Retry implements IRetryAnalyzer {
private int attempt = 1;
private static final int MAX_RETRY = 5;
@Override
public boolean retry(ITestResult iTestResult) {
if (!iTestResult.isSuccess()) {
if (attempt < MAX_RETRY) {
attempt++;
iTestResult.setStatus(ITestResult.FAILURE);
System.out.println("Retrying once again");
return true;
} else {
iTestResult.setStatus(ITestResult.FAILURE);
}
} else {
iTestResult.setStatus(ITestResult.SUCCESS);
}
return false;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment