All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.appium.utils.Retry Maven / Gradle / Ivy

There is a newer version: 9.0.1
Show newest version
package com.appium.utils;

import static com.appium.utils.ConfigFileManager.MAX_RETRY_COUNT;

import com.annotation.values.RetryCount;
import org.testng.IRetryAnalyzer;
import org.testng.ITestResult;

import java.util.concurrent.atomic.AtomicInteger;

public class Retry implements IRetryAnalyzer {
    private AtomicInteger COUNTER;

    public Retry() {
        COUNTER = new AtomicInteger(0);
    }

    @Override
    public boolean retry(ITestResult iTestResult) {
        int maxRetryCount;
        RetryCount annotation = iTestResult.getMethod().getConstructorOrMethod().getMethod()
                .getAnnotation(RetryCount.class);
        if (annotation != null) {
            maxRetryCount = annotation.maxRetryCount();
        } else {
            try {
                maxRetryCount = MAX_RETRY_COUNT.getInt();
            } catch (Exception e) {
                maxRetryCount = 0;
            }
        }
        return !iTestResult.isSuccess() && COUNTER.incrementAndGet() < maxRetryCount;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy