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: 14.0.4
Show newest version
package com.appium.utils;

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 ConfigFileManager prop;
    private AtomicInteger COUNTER;

    public Retry() {
        prop = ConfigFileManager.getInstance();
        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 = Integer.parseInt(prop.getProperty("MAX_RETRY_COUNT"));
            } catch (Exception e) {
                maxRetryCount = 0;
            }
        }
        return !iTestResult.isSuccess() && COUNTER.incrementAndGet() < maxRetryCount;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy