Created
July 13, 2023 11:33
-
-
Save hetacz/0eebc76396e7780b13da06f74f508104 to your computer and use it in GitHub Desktop.
RetryAnalyzer
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
@Slf4j | |
public class RetryAnalyzer extends RetryAnalyzerCount { | |
private static final Set<Class<? extends Throwable>> RETRYABLE_EXCEPTIONS = Set.of( | |
TimeoutException.class, | |
UnreachableBrowserException.class, | |
SessionNotCreatedException.class, | |
NoSuchSessionException.class, | |
ExceptionInInitializerError.class, | |
StaleElementReferenceException.class | |
); | |
public RetryAnalyzer() { | |
setCount(ConfigLoader.getInstance().getCorruptedTaskRetries()); | |
} | |
/** | |
* TODO: monitor which exceptions are the reason that automation is unstable, yet are not caused by errors in the app. | |
* Retry when these exceptions are thrown. | |
* <p> | |
* There is no point in retrying Groovy error (thrown by NullPointer), as it will occur again, only with different cause. | |
*/ | |
@Override | |
public boolean retryMethod(@NotNull ITestResult result) { | |
Throwable throwable = result.getThrowable(); | |
log.warn( | |
"Exception caught by listener details: Cause - {}, Message - {}.", | |
throwable.getCause(), | |
throwable.getMessage(), | |
throwable | |
); | |
return RETRYABLE_EXCEPTIONS.stream().anyMatch(throwable.getClass()::isAssignableFrom) || | |
throwable.getCause() instanceof TimeoutException; // for drivers' creation errors | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment