Using "alwaysRun=true" in @AfterGroup annotation isn't possible

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

Using "alwaysRun=true" in @AfterGroup annotation isn't possible

lilach
Hi Guys,
I'm building an automation framework for my company and I've bumped into a serious obstacle.
I'm using groups in order to gather tests with mutual preparations and cleanup, and I was surprised to see that the @AfterGroup annotation will not run if a test in the group is skipped, or in other words, if the @BeforeGroup method failed.
Is there a specific reason that the annotation attribute "alwaysRun=true" will not work specifically for @AfterGroup annotation, but will work for all other annotations?
Is it possible to change it\work around it?
The current implementation of groups is not relevant for cleanup scenarios, but there is also no other solution in TestNG for cleanup that is not a suite\test level cleanup.
Please help me!!!  (-:
Lilach

--
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: Using "alwaysRun=true" in @AfterGroup annotation isn't possible

Cédric Beust ♔-2

Configuration methods failing invalidates the run since all the bets are off when this happens.

Make sure your @BeforeGroups doesn’t fail (i.e. doesn’t throw, catch whatever might be thrown) and then you should see @AfterGroups being run.

-- 
Cédric


On Wed, Mar 2, 2016 at 7:39 AM, <[hidden email]> wrote:
Hi Guys,
I'm building an automation framework for my company and I've bumped into a serious obstacle.
I'm using groups in order to gather tests with mutual preparations and cleanup, and I was surprised to see that the @AfterGroup annotation will not run if a test in the group is skipped, or in other words, if the @BeforeGroup method failed.
Is there a specific reason that the annotation attribute "alwaysRun=true" will not work specifically for @AfterGroup annotation, but will work for all other annotations?
Is it possible to change it\work around it?
The current implementation of groups is not relevant for cleanup scenarios, but there is also no other solution in TestNG for cleanup that is not a suite\test level cleanup.
Please help me!!!  (-:
Lilach

--
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: Using "alwaysRun=true" in @AfterGroup annotation isn't possible

lilach
But that is exactly my problem: I want the @afterGroup to run when the @beforeGroup fails in order to perform cleanup and let the other tests run safely.
If I will put a "catch" clause in the @beforeGroup to prevent failure then the tests will run even though they are supposed to be skipped because their preparation failed, which is something I'm trying to avoid. Is there any way to force skipping a test via code? For example, force skipping a list of tests inside the @beforeGroups "catch" clause? 

On Sunday, March 6, 2016 at 5:35:43 PM UTC+2, Cédric Beust ♔ wrote:

Configuration methods failing invalidates the run since all the bets are off when this happens.

Make sure your @BeforeGroups doesn’t fail (i.e. doesn’t throw, catch whatever might be thrown) and then you should see @AfterGroups being run.

-- 
Cédric


On Wed, Mar 2, 2016 at 7:39 AM, <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="MIcwDwK1CQAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">lil...@...> wrote:
Hi Guys,
I'm building an automation framework for my company and I've bumped into a serious obstacle.
I'm using groups in order to gather tests with mutual preparations and cleanup, and I was surprised to see that the @AfterGroup annotation will not run if a test in the group is skipped, or in other words, if the @BeforeGroup method failed.
Is there a specific reason that the annotation attribute "alwaysRun=true" will not work specifically for @AfterGroup annotation, but will work for all other annotations?
Is it possible to change it\work around it?
The current implementation of groups is not relevant for cleanup scenarios, but there is also no other solution in TestNG for cleanup that is not a suite\test level cleanup.
Please help me!!!  (-:
Lilach

--
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="MIcwDwK1CQAJ" 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="MIcwDwK1CQAJ" 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.