how to run dependent test case while rerunning failed using retryanalyzer

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

how to run dependent test case while rerunning failed using retryanalyzer

Ravi Dunna

I have two test cases as test case 1 and test case 2

test case 2 depends upon test case 1

I am using retry analyzer as if test case 2 fails then it will be rerun but I need test case 1 also be invoked before test case 2 reruns

--
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
|

Re: how to run dependent test case while rerunning failed using retryanalyzer

Krishnan Mahadevan
Ravi,

Based on my understanding, I am elaborating your question with an example. [ If this is not what you were asking, I would request you to please help elaborate your question ]

public class TestClass {
@Test
public void independent() {
System.out.println("Hello World")
}
@Test(dependsOnMethods = "independent", retryAnalyzer = IRetryFailures.class)
public void dependent() {
//some logic goes here which is flaky enough to trigger failures
}
}


Your expectation is that, when the method dependent() has a failure and it is being retried by the retryAnalyser, you expect that independent() should also be invoked.

Explanation :

That is not how TestNG works.

When you mentioned that dependent() has a dependency on the method independent() then you have in a way established a pre-requisite for the method dependent() to be executed i.e., you have instructed TestNG : "Dear TestNG, please execute the method dependent() if and only if the method independent() passes".

Now the fact that the method dependent() was executed and it failed (for whatever reasons) and your retry analyser is being invoked emphasises that TestNG fulfilled your pre-requisite already. So why would it need to keep trying to fulfil the same pre-requisite every time the method dependent() is being retried by the retry analyser ? 

The retry analyser is expected to only attempt at retrying to current failed test method and not attempt at traversing up the hierarchy and try and fulfil every pre-requisite once again.

Please let me know if that explanation makes sense.

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/
My Technical Scribbings @ http://rationaleemotions.wordpress.com/

On Tue, Nov 22, 2016 at 8:19 PM, Ravi Dunna <[hidden email]> wrote:

I have two test cases as test case 1 and test case 2

test case 2 depends upon test case 1

I am using retry analyzer as if test case 2 fails then it will be rerun but I need test case 1 also be invoked before test case 2 reruns

--
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
|

Re: how to run dependent test case while rerunning failed using retryanalyzer

Sameer Jethvani
Exactly retryAnalyzer won't run preRequisites . In this case I would suggest to use testng's builtin feature (which is testng-failed.xml) file . Testng generates testng-failed.xml file after whole suite/tests are executed  , which you can directly execute . It will honor all kinda prerequisites/dependencies . The only different thing here is your failing tests won't get executed right after they fail , instead they will be executed once your whole suite gets excuted.

On Wednesday, November 23, 2016 at 9:45:35 AM UTC+5:30, Krishnan Mahadevan wrote:
Ravi,

Based on my understanding, I am elaborating your question with an example. [ If this is not what you were asking, I would request you to please help elaborate your question ]

public class TestClass {
@Test
public void independent() {
System.out.println("Hello World")
}
@Test(dependsOnMethods = "independent", retryAnalyzer = IRetryFailures.class)
public void dependent() {
//some logic goes here which is flaky enough to trigger failures
}
}


Your expectation is that, when the method dependent() has a failure and it is being retried by the retryAnalyser, you expect that independent() should also be invoked.

Explanation :

That is not how TestNG works.

When you mentioned that dependent() has a dependency on the method independent() then you have in a way established a pre-requisite for the method dependent() to be executed i.e., you have instructed TestNG : "Dear TestNG, please execute the method dependent() if and only if the method independent() passes".

Now the fact that the method dependent() was executed and it failed (for whatever reasons) and your retry analyser is being invoked emphasises that TestNG fulfilled your pre-requisite already. So why would it need to keep trying to fulfil the same pre-requisite every time the method dependent() is being retried by the retry analyser ? 

The retry analyser is expected to only attempt at retrying to current failed test method and not attempt at traversing up the hierarchy and try and fulfil every pre-requisite once again.

Please let me know if that explanation makes sense.

Thanks & Regards
Krishnan Mahadevan

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"
My Scribblings @ <a href="http://wakened-cognition.blogspot.com/" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fwakened-cognition.blogspot.com%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHzOdYJCASIDF_28vQtkp9gnKAYSQ&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fwakened-cognition.blogspot.com%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHzOdYJCASIDF_28vQtkp9gnKAYSQ&#39;;return true;">http://wakened-cognition.blogspot.com/
My Technical Scribbings @ <a href="http://rationaleemotions.wordpress.com/" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Frationaleemotions.wordpress.com%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEcBOKyRn0lpL8LDbBuyAlKdwgXwQ&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Frationaleemotions.wordpress.com%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEcBOKyRn0lpL8LDbBuyAlKdwgXwQ&#39;;return true;">http://rationaleemotions.wordpress.com/

On Tue, Nov 22, 2016 at 8:19 PM, Ravi Dunna <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="hA1ALvWcCgAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">ravi.te...@...> wrote:

I have two test cases as test case 1 and test case 2

test case 2 depends upon test case 1

I am using retry analyzer as if test case 2 fails then it will be rerun but I need test case 1 also be invoked before test case 2 reruns

--
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 <a href="javascript:" target="_blank" gdf-obfuscated-mailto="hA1ALvWcCgAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">testng-users...@googlegroups.com.
To post to this group, send email to <a href="javascript:" target="_blank" gdf-obfuscated-mailto="hA1ALvWcCgAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">testng...@....
Visit this group at <a href="https://groups.google.com/group/testng-users" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/group/testng-users&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/group/testng-users&#39;;return true;">https://groups.google.com/group/testng-users.
For more options, visit <a href="https://groups.google.com/d/optout" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;">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.