Quantcast

Retry Listner retrying passed test cases also and failed retry test is showing as skipped test

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Retry Listner retrying passed test cases also and failed retry test is showing as skipped test

Abhishek Bisht
Hi All,

I am using testng 6.9.6 and using retry listener but even passed test are running multiple times and failed tests are appearing as skipped test 

public class RetryListener  implements IAnnotationTransformer 
{

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

if (retry == null) {

testannotation.setRetryAnalyzer(RetryAnalyzer.class);

}

}


Retry class

public class RetryAnalyzer implements IRetryAnalyzer {
public int count = 0;

private int maxCount = 1;

public RetryAnalyzer() {
setCount(maxCount);
}

@Override
public boolean retry(ITestResult result) {

if (!(result.isSuccess())) {
if (count < maxCount) {
count++;
Reporter.log(Thread.currentThread().getName() + " Error in "
+ result.getName() + " with status "
+ result.getStatus() + " Retrying " + count + " times");
return true;
}

}
return false;
}

public void setCount(int count) {
maxCount = count;
}
}

Please help how can i handle and stop passed test from re runnning

--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Retry Listner retrying passed test cases also and failed retry test is showing as skipped test

Shawn McCarthy-2
Have you tried 6.9.9 or 6.9.10 or 6.9.11 ?

On Monday, April 18, 2016 at 11:01:53 PM UTC-7, Abhishek Bisht wrote:
Hi All,

I am using testng 6.9.6 and using retry listener but even passed test are running multiple times and failed tests are appearing as skipped test 

public class RetryListener  implements IAnnotationTransformer 
{

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

if (retry == null) {

testannotation.setRetryAnalyzer(RetryAnalyzer.class);

}

}


Retry class

public class RetryAnalyzer implements IRetryAnalyzer {
public int count = 0;

private int maxCount = 1;

public RetryAnalyzer() {
setCount(maxCount);
}

@Override
public boolean retry(ITestResult result) {

if (!(result.isSuccess())) {
if (count < maxCount) {
count++;
Reporter.log(Thread.currentThread().getName() + " Error in "
+ result.getName() + " with status "
+ result.getStatus() + " Retrying " + count + " times");
return true;
}

}
return false;
}

public void setCount(int count) {
maxCount = count;
}
}

Please help how can i handle and stop passed test from re runnning

--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Retry Listner retrying passed test cases also and failed retry test is showing as skipped test

Abhishek Bisht
Yes I have tried with testng 6.9.9 but again eve passed test cases are executed again

Regards
Abhishek Bisht
Contact no.- 9990421145

On Tue, Apr 19, 2016 at 9:45 PM, Shawn McCarthy <[hidden email]> wrote:
Have you tried 6.9.9 or 6.9.10 or 6.9.11 ?

On Monday, April 18, 2016 at 11:01:53 PM UTC-7, Abhishek Bisht wrote:
Hi All,

I am using testng 6.9.6 and using retry listener but even passed test are running multiple times and failed tests are appearing as skipped test 

public class RetryListener  implements IAnnotationTransformer 
{

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

if (retry == null) {

testannotation.setRetryAnalyzer(RetryAnalyzer.class);

}

}


Retry class

public class RetryAnalyzer implements IRetryAnalyzer {
public int count = 0;

private int maxCount = 1;

public RetryAnalyzer() {
setCount(maxCount);
}

@Override
public boolean retry(ITestResult result) {

if (!(result.isSuccess())) {
if (count < maxCount) {
count++;
Reporter.log(Thread.currentThread().getName() + " Error in "
+ result.getName() + " with status "
+ result.getStatus() + " Retrying " + count + " times");
return true;
}

}
return false;
}

public void setCount(int count) {
maxCount = count;
}
}

Please help how can i handle and stop passed test from re runnning

--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Retry Listner retrying passed test cases also and failed retry test is showing as skipped test

deepak gupta
In reply to this post by Shawn McCarthy-2
Hi All,

I am using TestNG 6.9.10 and facing  some issue's with  IAnnotationTransformer & IRetryAnalyzer interface's while implementing Retry logic for false failure.

1. Issue is : Suppose I want to retry failed test case two times, While execution its shows like Skip in First & second attempt & then fail.
    But at last its show  something like :
            Run 1: PASS
            Run 2: PASS
            Run 3: ********VerifyRateTableHas20Records:Intentionally fail!!!!!!!!! expected [true] but found [false]   
           and same thing has also been updated in reports as well.

Can someone please help me out???

   My Code :

   public class AnnotationTransformer implements IAnnotationTransformer {

    @Override
    public void transform(ITestAnnotation annotation, Class testClass, Constructor testConstructor, Method testMethod) {
        annotation.setRetryAnalyzer(Retry.class);
    }


public class Retry implements IRetryAnalyzer {

    private int count = 0;
    private static int maxTry = 3;

    @Override
    public boolean retry(ITestResult iTestResult) {
        if (!iTestResult.isSuccess()) {                      //Check if test not succeed
            if (count < maxTry) {                            //Check if maxtry count is reached
                count++;                                     //Increase the maxTry count by 1
                iTestResult.setStatus(ITestResult.FAILURE);  //Mark test as failed
                return true;                                 //Tells TestNG to re-run the test
            } else {
                iTestResult.setStatus(ITestResult.FAILURE);  //If maxCount reached,test marked as failed
            }
        } else {
            iTestResult.setStatus(ITestResult.SUCCESS);      //If test passes, TestNG marks it as passed
        }
        return false;
    }

}



On Tuesday, 19 April 2016 21:45:11 UTC+5:30, Shawn McCarthy wrote:
Have you tried 6.9.9 or 6.9.10 or 6.9.11 ?

On Monday, April 18, 2016 at 11:01:53 PM UTC-7, Abhishek Bisht wrote:
Hi All,

I am using testng 6.9.6 and using retry listener but even passed test are running multiple times and failed tests are appearing as skipped test 

public class RetryListener  implements IAnnotationTransformer 
{

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

if (retry == null) {

testannotation.setRetryAnalyzer(RetryAnalyzer.class);

}

}


Retry class

public class RetryAnalyzer implements IRetryAnalyzer {
public int count = 0;

private int maxCount = 1;

public RetryAnalyzer() {
setCount(maxCount);
}

@Override
public boolean retry(ITestResult result) {

if (!(result.isSuccess())) {
if (count < maxCount) {
count++;
Reporter.log(Thread.currentThread().getName() + " Error in "
+ result.getName() + " with status "
+ result.getStatus() + " Retrying " + count + " times");
return true;
}

}
return false;
}

public void setCount(int count) {
maxCount = count;
}
}

Please help how can i handle and stop passed test from re runnning

--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.
Loading...