Strange order execution of @AfterClass combined with @AfterTest

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

Strange order execution of @AfterClass combined with @AfterTest

Harmin Parra Rueda
Hi :

I have the following test java class :

@BeforeClass
setUp

@Test
method1

@AfterTest
method2

@AfterClass
tearDown

I realized that the actual order execution is :
@BeforeClass
@Test
@AfterClass
@AfterTest

My question to the TestNG developers :

Why not change the order execution to :
@BeforeClass
@Test
@AfterTest
@AfterClass

Thanks !!

--
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 http://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/groups/opt_out.
Reply | Threaded
Open this post in threaded view
|

Re: Strange order execution of @AfterClass combined with @AfterTest

⇜Krishnan Mahadevan⇝
And why you want that change ?
@BeforeTest and @AfterTest are designed to be invoked right before and after TestNG picks up @Test annotated test methods from a <test> Tag in a suite file. 

On Saturday, January 18, 2014, Harmin Rueda <[hidden email]> wrote:
Hi :

I have the following test java class :

@BeforeClass
setUp

@Test
method1

@AfterTest
method2

@AfterClass
tearDown

I realized that the actual order execution is :
@BeforeClass
@Test
@AfterClass
@AfterTest

My question to the TestNG developers :

Why not change the order execution to :
@BeforeClass
@Test
@AfterTest
@AfterClass

Thanks !!

--
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:_e({}, &#39;cvml&#39;, &#39;testng-users%2Bunsubscribe@googlegroups.com&#39;);" target="_blank">testng-users+unsubscribe@....
To post to this group, send email to <a href="javascript:_e({}, &#39;cvml&#39;, &#39;testng-users@googlegroups.com&#39;);" target="_blank">testng-users@....
Visit this group at http://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/groups/opt_out.


--
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 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 http://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/groups/opt_out.
Reply | Threaded
Open this post in threaded view
|

Re: Strange order execution of @AfterClass combined with @AfterTest

Harmin Parra Rueda
In reply to this post by Harmin Parra Rueda
Since @BeforeClass executes before @BeforeTest, I think the most logical thing is that @AfterTest should execute before @AfterClass.

The actual behavior of Testng is to execute @AfterClass before @AfterTest. Not logical !!!

Perhaps this is a bug of testng.

--
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 http://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/groups/opt_out.
Reply | Threaded
Open this post in threaded view
|

Re: Strange order execution of @AfterClass combined with @AfterTest

Yevhen Bilevych
Harming,

I'm afraid you are mistaken in your conclusion

The order is then following:
@BeforeTest
@BeforeClass
@Test
@AfterClass
@AfterTest

Yevhen

Sent from my BlackBerry® PlayBook™
www.blackberry.com


From: "Harmin Rueda" <[hidden email]>
To: "[hidden email]" <[hidden email]>
Sent: January 19, 2014 11:05 PM
Subject: [testng-users] Re: Strange order execution of @AfterClass combined with @AfterTest

Since @BeforeClass executes before @BeforeTest, I think the most logical thing is that @AfterTest should execute before @AfterClass.

The actual behavior of Testng is to execute @AfterClass before @AfterTest. Not logical !!!

Perhaps this is a bug of testng.

--
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 http://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/groups/opt_out.

--
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 http://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/groups/opt_out.
Reply | Threaded
Open this post in threaded view
|

Re: Strange order execution of @AfterClass combined with @AfterTest

Harmin Parra Rueda
In reply to this post by Harmin Parra Rueda
Yeah, that's right.

The actual order is

@BeforeTest
@BeforeClass
@Test
@AfterClass
@AfterTest

But I think that it is more logical to inverse the order : execute @AfterTest before @AfterClass


--
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 http://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/groups/opt_out.
Reply | Threaded
Open this post in threaded view
|

Re: Strange order execution of @AfterClass combined with @AfterTest

⇜Krishnan Mahadevan⇝
I still dont understand the rationale behind you feeling that its logical to inverse the order.
Why do you think that @AfterTest is supposed to be getting executed before @AfterClass

@AfterTest is designed to run after all the @Test annotated test methods that are part of a <test> have run to completion.

@AfterClass is designed to run after all the @Test annotated test methods that are part of a test class have run to completion.

A <test> can have one or more test classes.

So it only makes sense that @AfterClass run before and finally @AfterTest runs.

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/


On Tue, Jan 21, 2014 at 1:36 AM, Harmin Rueda <[hidden email]> wrote:
Yeah, that's right.

The actual order is

@BeforeTest
@BeforeClass
@Test
@AfterClass
@AfterTest

But I think that it is more logical to inverse the order : execute @AfterTest before @AfterClass


--
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 http://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/groups/opt_out.

--
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 http://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/groups/opt_out.
Reply | Threaded
Open this post in threaded view
|

AW: [testng-users] Re: Strange order execution of @AfterClass combined with @AfterTest

Hubert Grzeskowiak

Hi,
this whole confusion might come from the reuse of the term “test” which means something very different in XML-suites and in Java respectively. I think a term like “test-case” would be more appropriate in the context of Java.


@Harmin: what you are behind is probably @BeforeMethod and @AfterMethod. Those are run just before and after every @Test-annotated method.

Regards
Hubert Grzeskowiak

 

Von: [hidden email] [mailto:[hidden email]] Im Auftrag von Krishnan Mahadevan
Gesendet: Dienstag, 21. Januar 2014 07:08
An: [hidden email]
Betreff: Re: [testng-users] Re: Strange order execution of @AfterClass combined with @AfterTest

 

I still dont understand the rationale behind you feeling that its logical to inverse the order.

Why do you think that @AfterTest is supposed to be getting executed before @AfterClass

 

@AfterTest is designed to run after all the @Test annotated test methods that are part of a <test> have run to completion.

 

@AfterClass is designed to run after all the @Test annotated test methods that are part of a test class have run to completion.

 

A <test> can have one or more test classes.

 

So it only makes sense that @AfterClass run before and finally @AfterTest runs.


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/

 

On Tue, Jan 21, 2014 at 1:36 AM, Harmin Rueda <[hidden email]> wrote:

Yeah, that's right.

The actual order is

@BeforeTest

@BeforeClass

@Test

@AfterClass

@AfterTest

But I think that it is more logical to inverse the order : execute @AfterTest before @AfterClass

 

 

--
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 http://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/groups/opt_out.

 

--
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 http://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/groups/opt_out.

--
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 http://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/groups/opt_out.