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

listeners.Retry Maven / Gradle / Ivy

Go to download

A OyoTestLibs jar for deployment to the Central Repository via OSSRH

The newest version!
package com.oyo.listeners;

import org.testng.IRetryAnalyzer;
import org.testng.ITestResult;

/**
 * @author manish.kumar
 *
 */
public class Retry implements IRetryAnalyzer {

	private int retryCount = 0;
    private int maxRetryCount = 1;

    /*
     * @Input   : 'Result' as parameter of the test method that just ran
     * @returns : True if the test method has to be retried else False
     * 
     * @see org.testng.IRetryAnalyzer#retry(org.testng.ITestResult)
     */
    public boolean retry(ITestResult result) {
        if (retryCount < maxRetryCount) {
            System.out.println("Retrying to execute test " + result.getName() + " with status "
                    + getResultStatusName(result.getStatus()) + " for one more time.");
            retryCount++;
            return true;
        }
        return false;
    }
    
    public String getResultStatusName(int status) {
    	String resultName = null;
    	if(status==1)
    		resultName = "SUCCESS";
    	if(status==2)
    		resultName = "FAILURE";
    	if(status==3)
    		resultName = "SKIP";
		return resultName;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy