Created
November 17, 2024 17:52
-
-
Save borodicht/82f8fbb634d2ef8b153f19d8b4cbb90c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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