Re: [testng-users] testng skips dependency tests when dependent test passed on retry

1,126 views
Skip to first unread message

Krishnan Mahadevan

unread,
Sep 23, 2012, 9:20:20 AM9/23/12
to testng...@googlegroups.com, Shankar KC
Shankar,
What version of TestNG were you using?
How are you running your tests?

Perhaps you might wanna include this info as well!

On Sunday, September 23, 2012, shankar KC wrote:
Hi all,
 I have 2 tests. TestA and testB
TestA -> fails firsttime and passes on retry
TestB dependent on TestA using dependsOnMethods = "testA" attribute. 
TestA uses retry analyzer @Test(retryAnalyzer = RetryAnalyzer.class) so that it can be rerun on failure.

Now the current behavior as below :-
1. TestA fails for 1st attempt and get retried.
2. TestA passes in 2nd attempt.
3. TestB marked as skipped.

I would expect TestB not to get skipped as latest result of testA is pass.
I have attached source code here to repro the same. Please let me know how to make testB run on retry. I dont want it to get marked as skipped.
I did post the same question in testNG-DEV. I havnt received any reply yet. May be they are bit busy as lot of people will request answers to their questions. I think this is a common problem and many might have faced it and found some solution already. So i am posting my question here aswell.
Thanks
Shankar KC

--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/testng-users/-/bdSdkxFVXTYJ.
To post to this group, send email to testng...@googlegroups.com.
To unsubscribe from this group, send email to testng-users...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/testng-users?hl=en.


--
Thanks & Regards
Krishnan Mahadevan

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"
My Scribblings @ http://wakened-cognition.blogspot.com/

shankar KC

unread,
Sep 23, 2012, 11:10:47 AM9/23/12
to testng...@googlegroups.com, Shankar KC
I am using Latest version of testNG. testNG 6.8 I am running test using eclipse testNG plugin.
Thanks
Shankar KC


On Sunday, September 23, 2012 6:50:29 PM UTC+5:30, Krishnan wrote:
Shankar,
What version of TestNG were you using?
How are you running your tests?

Perhaps you might wanna include this info as well!

On Sunday, September 23, 2012, shankar KC wrote:
Hi all,
 I have 2 tests. TestA and testB
TestA -> fails firsttime and passes on retry
TestB dependent on TestA using dependsOnMethods = "testA" attribute. 
TestA uses retry analyzer @Test(retryAnalyzer = RetryAnalyzer.class) so that it can be rerun on failure.

Now the current behavior as below :-
1. TestA fails for 1st attempt and get retried.
2. TestA passes in 2nd attempt.
3. TestB marked as skipped.

I would expect TestB not to get skipped as latest result of testA is pass.
I have attached source code here to repro the same. Please let me know how to make testB run on retry. I dont want it to get marked as skipped.
I did post the same question in testNG-DEV. I havnt received any reply yet. May be they are bit busy as lot of people will request answers to their questions. I think this is a common problem and many might have faced it and found some solution already. So i am posting my question here aswell.
Thanks
Shankar KC

--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/testng-users/-/bdSdkxFVXTYJ.
To post to this group, send email to testng...@googlegroups.com.
To unsubscribe from this group, send email to testng-users+unsubscribe@googlegroups.com.

For more options, visit this group at http://groups.google.com/group/testng-users?hl=en.

shankar KC

unread,
Sep 23, 2012, 11:30:29 PM9/23/12
to testng...@googlegroups.com, Shankar KC
Now I am able to run the skipped test with this approach. Now the tests that are dependent are running but i still see that test suite reports that tests failed.
@Override
public boolean retry(ITestResult result) {
if (count < maxCount) {
result.setStatus(ITestResult.SKIP); // we set the status to skipped and remove this result so that on rerun if we have dependency it uses latest result.
result.getTestContext().getSkippedTests().removeResult(result.getMethod());
count++;
return true;
}
return false;

}
Though testNG shows all tests passed overall testsuite result showing suite as failure. It shows first iteration failure as failure exception. I have attached an image showing that. Any pointers to resolve the issue appreciated.
Thanks
Shankar KC
rerunFailedTests.jpg

soravikr

unread,
May 28, 2015, 11:44:22 AM5/28/15
to testng...@googlegroups.com, kcs...@yahoo-inc.com
I tried your solution to run the dependent testcases but it didnt work for me can you please help me.

shankar KC

unread,
May 28, 2015, 11:33:17 PM5/28/15
to testng...@googlegroups.com

Let me know the issue you are facing.  I will help. I will try to send accross code i wrote. It works for me.... Once i reach office i will update.

To unsubscribe from this group, send email to testng-users...@googlegroups.com.

For more options, visit this group at http://groups.google.com/group/testng-users?hl=en.


--
Thanks & Regards
Krishnan Mahadevan

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"
My Scribblings @ http://wakened-cognition.blogspot.com/

--
You received this message because you are subscribed to a topic in the Google Groups "testng-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/testng-users/WMNZ5uzM6DE/unsubscribe.
To unsubscribe from this group and all its topics, send an email to testng-users...@googlegroups.com.

To post to this group, send email to testng...@googlegroups.com.

soravikr

unread,
May 29, 2015, 12:11:55 AM5/29/15
to testng...@googlegroups.com
Even though a testcase passes in retry its dependent testcases are skipped.As you mentioned I made the result of the testcase skip and removed from the results even then the dependent testcase skips.
To unsubscribe from this group, send email to testng-users+unsubscribe@googlegroups.com.

For more options, visit this group at http://groups.google.com/group/testng-users?hl=en.


--
Thanks & Regards
Krishnan Mahadevan

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"
My Scribblings @ http://wakened-cognition.blogspot.com/

soravikr

unread,
May 29, 2015, 1:09:12 AM5/29/15
to testng...@googlegroups.com
Hi Shankar,

           Thanks for you reply.your solution worked...Thank you so much :)

shankar KC

unread,
May 29, 2015, 5:16:15 AM5/29/15
to testng...@googlegroups.com

Np glad it worked for you

Hi Shankar,

To unsubscribe from this group, send email to testng-users...@googlegroups.com.

For more options, visit this group at http://groups.google.com/group/testng-users?hl=en.


--
Thanks & Regards
Krishnan Mahadevan

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"
My Scribblings @ http://wakened-cognition.blogspot.com/

--
You received this message because you are subscribed to a topic in the Google Groups "testng-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/testng-users/WMNZ5uzM6DE/unsubscribe.
To unsubscribe from this group and all its topics, send an email to testng-users...@googlegroups.com.
To post to this group, send email to testng...@googlegroups.com.
Visit this group at http://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.

nisha...@gmail.com

unread,
Jun 24, 2015, 5:31:24 PM6/24/15
to testng...@googlegroups.com
Hi Shankar,
                I am facing the same issue, can you share the code that worked for Soravikr.

Thank you,
Karthika
Hi Shankar,

To unsubscribe from this group, send email to testng-users+unsubscribe@googlegroups.com.

For more options, visit this group at http://groups.google.com/group/testng-users?hl=en.


--
Thanks & Regards
Krishnan Mahadevan

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"
My Scribblings @ http://wakened-cognition.blogspot.com/

--
You received this message because you are subscribed to a topic in the Google Groups "testng-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/testng-users/WMNZ5uzM6DE/unsubscribe.
To unsubscribe from this group and all its topics, send an email to testng-users...@googlegroups.com.
To post to this group, send email to testng...@googlegroups.com.
Visit this group at http://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.

soravikr

unread,
Jun 25, 2015, 1:39:27 AM6/25/15
to testng...@googlegroups.com
Hi Karthika,

              In my case,There are testcases that depend on another testcase. If the first testcase fails and passed in retry its dependent testcases are skipped.

              If your issue is same as this,you can use the below solution It worked for me.

              result.getTestContext().getFailedTests().removeResult(result.getMethod());

              Include the above line in retry method 

Jigs

unread,
Jan 31, 2018, 10:56:36 PM1/31/18
to testng-users
@soravikr,

My dependency tests are still getting skipped.

This is my RetryAnalyzer class:

@Override

public boolean retry(final ITestResult result) {

if (isRetryAvailable()) {

if (counter <= retryLimit) {

result.setStatus(ITestResult.SKIP);

result.getTestContext().getFailedTests().removeResult(result);

result.getTestContext().getSkippedTests().removeResult(result);

counter++;

String message = Thread.currentThread().getName() + ": Error in " + result.getName()

+ " [result.getMethod(): " + result.getMethod() + " ] Retrying " + (retryLimit + 1 - counter)

+ " more times";

System.out.println(message);

return true;

}


System.out.println("Exhausted retries for test case " + result.getMethod());

}

return false;

}



I am facing these 2 issues:
  1. Dependency Tests are not running even when the dependent test passes after initial failure.
  2. In the Report, the run is marked as Fail
Any help would be really appreciated.

Best,
Jigs

gowthami

unread,
Mar 13, 2018, 7:02:24 AM3/13/18
to testng-users
Hi,

Following is the retry method I have used and it is not working. Can anyone please help me with this.
    @Override
public boolean retry(final ITestResult result) {
        if (!result.isSuccess()) {
if (counter < retryLimit) {
result.getTestContext().getFailedTests().removeResult(result);
result.getTestContext().getSkippedTests().removeResult(result);
counter++;
return true;
} else {
result.setStatus(ITestResult.FAILURE);

}
} else {
result.setStatus(ITestResult.SUCCESS);
}
return false;
}


On Sunday, September 23, 2012 at 6:50:20 PM UTC+5:30, Krishnan Mahadevan wrote:
Shankar,
What version of TestNG were you using?
How are you running your tests?

Perhaps you might wanna include this info as well!

On Sunday, September 23, 2012, shankar KC wrote:
Hi all,
 I have 2 tests. TestA and testB
TestA -> fails firsttime and passes on retry
TestB dependent on TestA using dependsOnMethods = "testA" attribute. 
TestA uses retry analyzer @Test(retryAnalyzer = RetryAnalyzer.class) so that it can be rerun on failure.

Now the current behavior as below :-
1. TestA fails for 1st attempt and get retried.
2. TestA passes in 2nd attempt.
3. TestB marked as skipped.

I would expect TestB not to get skipped as latest result of testA is pass.
I have attached source code here to repro the same. Please let me know how to make testB run on retry. I dont want it to get marked as skipped.
I did post the same question in testNG-DEV. I havnt received any reply yet. May be they are bit busy as lot of people will request answers to their questions. I think this is a common problem and many might have faced it and found some solution already. So i am posting my question here aswell.
Thanks
Shankar KC

--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/testng-users/-/bdSdkxFVXTYJ.
To post to this group, send email to testng...@googlegroups.com.
To unsubscribe from this group, send email to testng-users+unsubscribe@googlegroups.com.

For more options, visit this group at http://groups.google.com/group/testng-users?hl=en.
Reply all
Reply to author
Forward
0 new messages