mardi 13 septembre 2016

Remove (duplicate) failed TestNG result via rerun tests

I added rerun test by Testng, but have a problem with duplicate tests in test report. Could you help me with this

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

@Override
public boolean retry(ITestResult result) {
    if (retryCount < maxRetryCount) {
        System.out.println("Retrying test " + result.getName() + " with status "
                + getResultStatusName(result.getStatus()) + " for the " + (retryCount+1) + " time(s).");
        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;
}

And

public class RetryListener implements IAnnotationTransformer {

@Override
public void transform(ITestAnnotation testannotation, Class testClass,
                      Constructor testConstructor, Method testMethod)   {
    IRetryAnalyzer retry = testannotation.getRetryAnalyzer();

    if (retry == null)  {
        testannotation.setRetryAnalyzer(iOpiumListener.class);
    }

}

}

But in test report displayed or two failed or one passed and one failed test

Aucun commentaire:

Enregistrer un commentaire