Specifics of @BeforeClass and @AfterClass execution order

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

Specifics of @BeforeClass and @AfterClass execution order

peter sgouros
at what point are the @Before and @After class annotated methods (actually and intended?) meant to run?

For a variety of reasons I need to run a set of complex test cases sequentially (i.e. parallel=none, thread-count=1) though not in any particular order. In each case, I need to set up a complex environment, run the tests, then tear down the complex environment before moving on to the next test case where I will need to set up a new (but different and potentially conflicting) environment.  but my hope and expectation is that the entire test class is executed before proceeding to the next test case.  after a fair amount of experimentation and searching it appears to me that the @BeforeClass and @AfterClass methods may be executed at any arbitrary time providing that the time is indeed before or after the test methods within the class in question. as a result, the @AfterClass method may not execute (going by the log file) until potentially several test class executions later. causing my environments to conflict

am I incorrect in assuming that the @AfterClass method of one test class should execute before the @BeforeClass method of another test class?

how is it, when running in what appears to be be single threaded conditions, the test runner still seems to be intent on running the @AfterClasses in arbitrary order or at arbitrary times?

is there a way to configure testng such that each test class run to completion (with all associated @BeforeClass and @AfterClass methods) before proceeding to the next test class?

what is occurring now is that (for example) the @AfterClass methods are being invoked not at the end of the test class they are attached to, but at a later time, often in the middle of one of the subsequent test classes. sometimes just after the @BeforeClass method has been invoked for the next class. this is causing issues. as the before and after methods are counterparts. the test methods depend on things created by the @before.  is this really the intended operation for this feature?

the one viable (but annoying) option I have found is to place the @AfterClass actions into a test method and either set up a dependency chain or priority order which seems to be at odds with general good test practice. has anyone any other viable options?

or alternatively setup a testng.xml file that lists each test case a as a separate suite or something similar.  what I really want to know is whether the current behavior of the @BeforeClass and @AfterClass annotations is a feature or a bug.

cheers

--
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: Specifics of @BeforeClass and @AfterClass execution order

akash kansal

On Wed, Jun 13, 2018 at 4:31 AM, peter sgouros <[hidden email]> wrote:
at what point are the @Before and @After class annotated methods (actually and intended?) meant to run?

For a variety of reasons I need to run a set of complex test cases sequentially (i.e. parallel=none, thread-count=1) though not in any particular order. In each case, I need to set up a complex environment, run the tests, then tear down the complex environment before moving on to the next test case where I will need to set up a new (but different and potentially conflicting) environment.  but my hope and expectation is that the entire test class is executed before proceeding to the next test case.  after a fair amount of experimentation and searching it appears to me that the @BeforeClass and @AfterClass methods may be executed at any arbitrary time providing that the time is indeed before or after the test methods within the class in question. as a result, the @AfterClass method may not execute (going by the log file) until potentially several test class executions later. causing my environments to conflict

am I incorrect in assuming that the @AfterClass method of one test class should execute before the @BeforeClass method of another test class?

how is it, when running in what appears to be be single threaded conditions, the test runner still seems to be intent on running the @AfterClasses in arbitrary order or at arbitrary times?

is there a way to configure testng such that each test class run to completion (with all associated @BeforeClass and @AfterClass methods) before proceeding to the next test class?

what is occurring now is that (for example) the @AfterClass methods are being invoked not at the end of the test class they are attached to, but at a later time, often in the middle of one of the subsequent test classes. sometimes just after the @BeforeClass method has been invoked for the next class. this is causing issues. as the before and after methods are counterparts. the test methods depend on things created by the @before.  is this really the intended operation for this feature?

the one viable (but annoying) option I have found is to place the @AfterClass actions into a test method and either set up a dependency chain or priority order which seems to be at odds with general good test practice. has anyone any other viable options?

or alternatively setup a testng.xml file that lists each test case a as a separate suite or something similar.  what I really want to know is whether the current behavior of the @BeforeClass and @AfterClass annotations is a feature or a bug.

cheers

--
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: Specifics of @BeforeClass and @AfterClass execution order

khushboo vyas
In reply to this post by peter sgouros
Hi peter, I think it might help you, try to use @BeforeClass or @BeforeTest with the function that you have created to set up your complex environment and then after that likewise you can use @AfterClass or @AfterTest to your tear down function. 

On Wed, Jun 13, 2018 at 4:31 AM, peter sgouros <[hidden email]> wrote:
at what point are the @Before and @After class annotated methods (actually and intended?) meant to run?

For a variety of reasons I need to run a set of complex test cases sequentially (i.e. parallel=none, thread-count=1) though not in any particular order. In each case, I need to set up a complex environment, run the tests, then tear down the complex environment before moving on to the next test case where I will need to set up a new (but different and potentially conflicting) environment.  but my hope and expectation is that the entire test class is executed before proceeding to the next test case.  after a fair amount of experimentation and searching it appears to me that the @BeforeClass and @AfterClass methods may be executed at any arbitrary time providing that the time is indeed before or after the test methods within the class in question. as a result, the @AfterClass method may not execute (going by the log file) until potentially several test class executions later. causing my environments to conflict

am I incorrect in assuming that the @AfterClass method of one test class should execute before the @BeforeClass method of another test class?

how is it, when running in what appears to be be single threaded conditions, the test runner still seems to be intent on running the @AfterClasses in arbitrary order or at arbitrary times?

is there a way to configure testng such that each test class run to completion (with all associated @BeforeClass and @AfterClass methods) before proceeding to the next test class?

what is occurring now is that (for example) the @AfterClass methods are being invoked not at the end of the test class they are attached to, but at a later time, often in the middle of one of the subsequent test classes. sometimes just after the @BeforeClass method has been invoked for the next class. this is causing issues. as the before and after methods are counterparts. the test methods depend on things created by the @before.  is this really the intended operation for this feature?

the one viable (but annoying) option I have found is to place the @AfterClass actions into a test method and either set up a dependency chain or priority order which seems to be at odds with general good test practice. has anyone any other viable options?

or alternatively setup a testng.xml file that lists each test case a as a separate suite or something similar.  what I really want to know is whether the current behavior of the @BeforeClass and @AfterClass annotations is a feature or a bug.

cheers

--
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: Specifics of @BeforeClass and @AfterClass execution order

TotalQA
Hi All,

You  can find the complete hierarchy of all Testng 13 Annotations in this link.


Regards,
total-qa.com.

On Thursday, June 14, 2018 at 12:50:02 PM UTC+5:30, khushboo vyas wrote:
Hi peter, I think it might help you, try to use @BeforeClass or @BeforeTest with the function that you have created to set up your complex environment and then after that likewise you can use @AfterClass or @AfterTest to your tear down function. 

On Wed, Jun 13, 2018 at 4:31 AM, peter sgouros <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="9he6yGvNAgAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">psgo...@...> wrote:
at what point are the @Before and @After class annotated methods (actually and intended?) meant to run?

For a variety of reasons I need to run a set of complex test cases sequentially (i.e. parallel=none, thread-count=1) though not in any particular order. In each case, I need to set up a complex environment, run the tests, then tear down the complex environment before moving on to the next test case where I will need to set up a new (but different and potentially conflicting) environment.  but my hope and expectation is that the entire test class is executed before proceeding to the next test case.  after a fair amount of experimentation and searching it appears to me that the @BeforeClass and @AfterClass methods may be executed at any arbitrary time providing that the time is indeed before or after the test methods within the class in question. as a result, the @AfterClass method may not execute (going by the log file) until potentially several test class executions later. causing my environments to conflict

am I incorrect in assuming that the @AfterClass method of one test class should execute before the @BeforeClass method of another test class?

how is it, when running in what appears to be be single threaded conditions, the test runner still seems to be intent on running the @AfterClasses in arbitrary order or at arbitrary times?

is there a way to configure testng such that each test class run to completion (with all associated @BeforeClass and @AfterClass methods) before proceeding to the next test class?

what is occurring now is that (for example) the @AfterClass methods are being invoked not at the end of the test class they are attached to, but at a later time, often in the middle of one of the subsequent test classes. sometimes just after the @BeforeClass method has been invoked for the next class. this is causing issues. as the before and after methods are counterparts. the test methods depend on things created by the @before.  is this really the intended operation for this feature?

the one viable (but annoying) option I have found is to place the @AfterClass actions into a test method and either set up a dependency chain or priority order which seems to be at odds with general good test practice. has anyone any other viable options?

or alternatively setup a testng.xml file that lists each test case a as a separate suite or something similar.  what I really want to know is whether the current behavior of the @BeforeClass and @AfterClass annotations is a feature or a bug.

cheers

--
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="9he6yGvNAgAJ" 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="9he6yGvNAgAJ" 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.
Reply | Threaded
Open this post in threaded view
|

Re: Specifics of @BeforeClass and @AfterClass execution order

peter sgouros
In reply to this post by akash kansal
I'm aware of the documented behavior, what I'm concerned about is that the evidence of my tests indicate that testng is not following the described behavior pattern.
if you imagine that I have 2 test classes, call them A and B. each has a @BeforeClass, @AfterClass and several test methods. what I am seeing as my tests run is that (assuming they occur in the order A, B) is that the B.BeforeClass is executed before the A.AfterClass. and A.AfterClass may actually be occurring after the first B.TestMethod is occurring.  In my case the test cases are built relying on the fact that they can be run in isolation and in any order, meaning that they clean up after themselves. if A cleans up after B is started, it may (and is) affecting the environment in a way that causes test B to fail.

On Wed, Jun 13, 2018 at 9:24 AM akash kansal <[hidden email]> wrote:

On Wed, Jun 13, 2018 at 4:31 AM, peter sgouros <[hidden email]> wrote:
at what point are the @Before and @After class annotated methods (actually and intended?) meant to run?

For a variety of reasons I need to run a set of complex test cases sequentially (i.e. parallel=none, thread-count=1) though not in any particular order. In each case, I need to set up a complex environment, run the tests, then tear down the complex environment before moving on to the next test case where I will need to set up a new (but different and potentially conflicting) environment.  but my hope and expectation is that the entire test class is executed before proceeding to the next test case.  after a fair amount of experimentation and searching it appears to me that the @BeforeClass and @AfterClass methods may be executed at any arbitrary time providing that the time is indeed before or after the test methods within the class in question. as a result, the @AfterClass method may not execute (going by the log file) until potentially several test class executions later. causing my environments to conflict

am I incorrect in assuming that the @AfterClass method of one test class should execute before the @BeforeClass method of another test class?

how is it, when running in what appears to be be single threaded conditions, the test runner still seems to be intent on running the @AfterClasses in arbitrary order or at arbitrary times?

is there a way to configure testng such that each test class run to completion (with all associated @BeforeClass and @AfterClass methods) before proceeding to the next test class?

what is occurring now is that (for example) the @AfterClass methods are being invoked not at the end of the test class they are attached to, but at a later time, often in the middle of one of the subsequent test classes. sometimes just after the @BeforeClass method has been invoked for the next class. this is causing issues. as the before and after methods are counterparts. the test methods depend on things created by the @before.  is this really the intended operation for this feature?

the one viable (but annoying) option I have found is to place the @AfterClass actions into a test method and either set up a dependency chain or priority order which seems to be at odds with general good test practice. has anyone any other viable options?

or alternatively setup a testng.xml file that lists each test case a as a separate suite or something similar.  what I really want to know is whether the current behavior of the @BeforeClass and @AfterClass annotations is a feature or a bug.

cheers

--
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 a topic in the Google Groups "testng-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/testng-users/nVgH6F-TIBo/unsubscribe.
To unsubscribe from this group and all its topics, 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.


--
Peter Sgouros

--
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: Specifics of @BeforeClass and @AfterClass execution order

peter sgouros
In reply to this post by khushboo vyas
this is indeed what I am trying to do, but there seems to be an issue with how (an when) the Before and After Class methods are being called, causing the difficulty.

On Thu, Jun 14, 2018 at 12:20 AM khushboo vyas <[hidden email]> wrote:
Hi peter, I think it might help you, try to use @BeforeClass or @BeforeTest with the function that you have created to set up your complex environment and then after that likewise you can use @AfterClass or @AfterTest to your tear down function. 

On Wed, Jun 13, 2018 at 4:31 AM, peter sgouros <[hidden email]> wrote:
at what point are the @Before and @After class annotated methods (actually and intended?) meant to run?

For a variety of reasons I need to run a set of complex test cases sequentially (i.e. parallel=none, thread-count=1) though not in any particular order. In each case, I need to set up a complex environment, run the tests, then tear down the complex environment before moving on to the next test case where I will need to set up a new (but different and potentially conflicting) environment.  but my hope and expectation is that the entire test class is executed before proceeding to the next test case.  after a fair amount of experimentation and searching it appears to me that the @BeforeClass and @AfterClass methods may be executed at any arbitrary time providing that the time is indeed before or after the test methods within the class in question. as a result, the @AfterClass method may not execute (going by the log file) until potentially several test class executions later. causing my environments to conflict

am I incorrect in assuming that the @AfterClass method of one test class should execute before the @BeforeClass method of another test class?

how is it, when running in what appears to be be single threaded conditions, the test runner still seems to be intent on running the @AfterClasses in arbitrary order or at arbitrary times?

is there a way to configure testng such that each test class run to completion (with all associated @BeforeClass and @AfterClass methods) before proceeding to the next test class?

what is occurring now is that (for example) the @AfterClass methods are being invoked not at the end of the test class they are attached to, but at a later time, often in the middle of one of the subsequent test classes. sometimes just after the @BeforeClass method has been invoked for the next class. this is causing issues. as the before and after methods are counterparts. the test methods depend on things created by the @before.  is this really the intended operation for this feature?

the one viable (but annoying) option I have found is to place the @AfterClass actions into a test method and either set up a dependency chain or priority order which seems to be at odds with general good test practice. has anyone any other viable options?

or alternatively setup a testng.xml file that lists each test case a as a separate suite or something similar.  what I really want to know is whether the current behavior of the @BeforeClass and @AfterClass annotations is a feature or a bug.

cheers

--
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 a topic in the Google Groups "testng-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/testng-users/nVgH6F-TIBo/unsubscribe.
To unsubscribe from this group and all its topics, 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.


--
Peter Sgouros

--
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: Specifics of @BeforeClass and @AfterClass execution order

akash kansal
In reply to this post by peter sgouros
Hi Peter ,

Can you share your project repository/git link.
As, the scenario you are taking working fine in my case.

Are you using selenium web driver or simple test.

On Thu, Jun 14, 2018 at 10:56 PM, peter sgouros <[hidden email]> wrote:
I'm aware of the documented behavior, what I'm concerned about is that the evidence of my tests indicate that testng is not following the described behavior pattern.
if you imagine that I have 2 test classes, call them A and B. each has a @BeforeClass, @AfterClass and several test methods. what I am seeing as my tests run is that (assuming they occur in the order A, B) is that the B.BeforeClass is executed before the A.AfterClass. and A.AfterClass may actually be occurring after the first B.TestMethod is occurring.  In my case the test cases are built relying on the fact that they can be run in isolation and in any order, meaning that they clean up after themselves. if A cleans up after B is started, it may (and is) affecting the environment in a way that causes test B to fail.

On Wed, Jun 13, 2018 at 9:24 AM akash kansal <[hidden email]> wrote:

On Wed, Jun 13, 2018 at 4:31 AM, peter sgouros <[hidden email]> wrote:
at what point are the @Before and @After class annotated methods (actually and intended?) meant to run?

For a variety of reasons I need to run a set of complex test cases sequentially (i.e. parallel=none, thread-count=1) though not in any particular order. In each case, I need to set up a complex environment, run the tests, then tear down the complex environment before moving on to the next test case where I will need to set up a new (but different and potentially conflicting) environment.  but my hope and expectation is that the entire test class is executed before proceeding to the next test case.  after a fair amount of experimentation and searching it appears to me that the @BeforeClass and @AfterClass methods may be executed at any arbitrary time providing that the time is indeed before or after the test methods within the class in question. as a result, the @AfterClass method may not execute (going by the log file) until potentially several test class executions later. causing my environments to conflict

am I incorrect in assuming that the @AfterClass method of one test class should execute before the @BeforeClass method of another test class?

how is it, when running in what appears to be be single threaded conditions, the test runner still seems to be intent on running the @AfterClasses in arbitrary order or at arbitrary times?

is there a way to configure testng such that each test class run to completion (with all associated @BeforeClass and @AfterClass methods) before proceeding to the next test class?

what is occurring now is that (for example) the @AfterClass methods are being invoked not at the end of the test class they are attached to, but at a later time, often in the middle of one of the subsequent test classes. sometimes just after the @BeforeClass method has been invoked for the next class. this is causing issues. as the before and after methods are counterparts. the test methods depend on things created by the @before.  is this really the intended operation for this feature?

the one viable (but annoying) option I have found is to place the @AfterClass actions into a test method and either set up a dependency chain or priority order which seems to be at odds with general good test practice. has anyone any other viable options?

or alternatively setup a testng.xml file that lists each test case a as a separate suite or something similar.  what I really want to know is whether the current behavior of the @BeforeClass and @AfterClass annotations is a feature or a bug.

cheers

--
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 a topic in the Google Groups "testng-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/testng-users/nVgH6F-TIBo/unsubscribe.
To unsubscribe from this group and all its topics, 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.


--
Peter Sgouros

--
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: Specifics of @BeforeClass and @AfterClass execution order

khushboo vyas
Not sure but, If you have one environment set up that ur using for both A and B class, in that case you can create one separate Utility class with @AfterClass and @BeforeClass and define your environment setup there, after that you can extend same utility class with Both of your classes as "class A extends UtilityClass" and class B extends UtilityClass" .

On Fri, Jun 15, 2018 at 7:22 AM, akash kansal <[hidden email]> wrote:
Hi Peter ,

Can you share your project repository/git link.
As, the scenario you are taking working fine in my case.

Are you using selenium web driver or simple test.

On Thu, Jun 14, 2018 at 10:56 PM, peter sgouros <[hidden email]> wrote:
I'm aware of the documented behavior, what I'm concerned about is that the evidence of my tests indicate that testng is not following the described behavior pattern.
if you imagine that I have 2 test classes, call them A and B. each has a @BeforeClass, @AfterClass and several test methods. what I am seeing as my tests run is that (assuming they occur in the order A, B) is that the B.BeforeClass is executed before the A.AfterClass. and A.AfterClass may actually be occurring after the first B.TestMethod is occurring.  In my case the test cases are built relying on the fact that they can be run in isolation and in any order, meaning that they clean up after themselves. if A cleans up after B is started, it may (and is) affecting the environment in a way that causes test B to fail.

On Wed, Jun 13, 2018 at 9:24 AM akash kansal <[hidden email]> wrote:

On Wed, Jun 13, 2018 at 4:31 AM, peter sgouros <[hidden email]> wrote:
at what point are the @Before and @After class annotated methods (actually and intended?) meant to run?

For a variety of reasons I need to run a set of complex test cases sequentially (i.e. parallel=none, thread-count=1) though not in any particular order. In each case, I need to set up a complex environment, run the tests, then tear down the complex environment before moving on to the next test case where I will need to set up a new (but different and potentially conflicting) environment.  but my hope and expectation is that the entire test class is executed before proceeding to the next test case.  after a fair amount of experimentation and searching it appears to me that the @BeforeClass and @AfterClass methods may be executed at any arbitrary time providing that the time is indeed before or after the test methods within the class in question. as a result, the @AfterClass method may not execute (going by the log file) until potentially several test class executions later. causing my environments to conflict

am I incorrect in assuming that the @AfterClass method of one test class should execute before the @BeforeClass method of another test class?

how is it, when running in what appears to be be single threaded conditions, the test runner still seems to be intent on running the @AfterClasses in arbitrary order or at arbitrary times?

is there a way to configure testng such that each test class run to completion (with all associated @BeforeClass and @AfterClass methods) before proceeding to the next test class?

what is occurring now is that (for example) the @AfterClass methods are being invoked not at the end of the test class they are attached to, but at a later time, often in the middle of one of the subsequent test classes. sometimes just after the @BeforeClass method has been invoked for the next class. this is causing issues. as the before and after methods are counterparts. the test methods depend on things created by the @before.  is this really the intended operation for this feature?

the one viable (but annoying) option I have found is to place the @AfterClass actions into a test method and either set up a dependency chain or priority order which seems to be at odds with general good test practice. has anyone any other viable options?

or alternatively setup a testng.xml file that lists each test case a as a separate suite or something similar.  what I really want to know is whether the current behavior of the @BeforeClass and @AfterClass annotations is a feature or a bug.

cheers

--
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 a topic in the Google Groups "testng-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/testng-users/nVgH6F-TIBo/unsubscribe.
To unsubscribe from this group and all its topics, 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.


--
Peter Sgouros

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

--
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: Specifics of @BeforeClass and @AfterClass execution order

Ram Vishwakarma
In reply to this post by khushboo vyas
Hello Team,

Currently, I'm new for automation but at my level, I achieving something good, I establish one framework for automation.
In my framework, I'm using TestNG with Page Object Model and for reporting, we are using the Extent report.
But in my application mostly test cases are failed due to the performance issue, I handle this situation with the help of IRetryAnalyzer
I'm using extent report for reporting issues but in this report failed test cases lock in multiple time, how to lock the last status for the executed test case.
please help me.....

Regards,
Ram Vishwakarma

On Thu, Jun 14, 2018 at 12:49 PM, khushboo vyas <[hidden email]> wrote:
Hi peter, I think it might help you, try to use @BeforeClass or @BeforeTest with the function that you have created to set up your complex environment and then after that likewise you can use @AfterClass or @AfterTest to your tear down function. 

On Wed, Jun 13, 2018 at 4:31 AM, peter sgouros <[hidden email]> wrote:
at what point are the @Before and @After class annotated methods (actually and intended?) meant to run?

For a variety of reasons I need to run a set of complex test cases sequentially (i.e. parallel=none, thread-count=1) though not in any particular order. In each case, I need to set up a complex environment, run the tests, then tear down the complex environment before moving on to the next test case where I will need to set up a new (but different and potentially conflicting) environment.  but my hope and expectation is that the entire test class is executed before proceeding to the next test case.  after a fair amount of experimentation and searching it appears to me that the @BeforeClass and @AfterClass methods may be executed at any arbitrary time providing that the time is indeed before or after the test methods within the class in question. as a result, the @AfterClass method may not execute (going by the log file) until potentially several test class executions later. causing my environments to conflict

am I incorrect in assuming that the @AfterClass method of one test class should execute before the @BeforeClass method of another test class?

how is it, when running in what appears to be be single threaded conditions, the test runner still seems to be intent on running the @AfterClasses in arbitrary order or at arbitrary times?

is there a way to configure testng such that each test class run to completion (with all associated @BeforeClass and @AfterClass methods) before proceeding to the next test class?

what is occurring now is that (for example) the @AfterClass methods are being invoked not at the end of the test class they are attached to, but at a later time, often in the middle of one of the subsequent test classes. sometimes just after the @BeforeClass method has been invoked for the next class. this is causing issues. as the before and after methods are counterparts. the test methods depend on things created by the @before.  is this really the intended operation for this feature?

the one viable (but annoying) option I have found is to place the @AfterClass actions into a test method and either set up a dependency chain or priority order which seems to be at odds with general good test practice. has anyone any other viable options?

or alternatively setup a testng.xml file that lists each test case a as a separate suite or something similar.  what I really want to know is whether the current behavior of the @BeforeClass and @AfterClass annotations is a feature or a bug.

cheers

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



--
Regards,
Ramniwas Vishwakarma
Cell No. :- 9977050509

--
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: Specifics of @BeforeClass and @AfterClass execution order

Krishnan Mahadevan

Ram,

Please DONOT hijack threads.

For your query, please post a new query on the forum.

And when you post, don’t forget to include sample code etc., that we can look at.

 

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/

 

From: <[hidden email]> on behalf of Ram Vishwakarma <[hidden email]>
Reply-To: <[hidden email]>
Date: Friday, June 15, 2018 at 7:45 PM
To: <[hidden email]>
Subject: Re: [testng-users] Specifics of @BeforeClass and @AfterClass execution order

 

Hello Team,

 

Currently, I'm new for automation but at my level, I achieving something good, I establish one framework for automation.

In my framework, I'm using TestNG with Page Object Model and for reporting, we are using the Extent report.

But in my application mostly test cases are failed due to the performance issue, I handle this situation with the help of IRetryAnalyzer

I'm using extent report for reporting issues but in this report failed test cases lock in multiple time, how to lock the last status for the executed test case.

please help me.....

 

Regards,

Ram Vishwakarma

 

On Thu, Jun 14, 2018 at 12:49 PM, khushboo vyas <[hidden email]> wrote:

Hi peter, I think it might help you, try to use @BeforeClass or @BeforeTest with the function that you have created to set up your complex environment and then after that likewise you can use @AfterClass or @AfterTest to your tear down function. 

 

On Wed, Jun 13, 2018 at 4:31 AM, peter sgouros <[hidden email]> wrote:

at what point are the @Before and @After class annotated methods (actually and intended?) meant to run?

 

For a variety of reasons I need to run a set of complex test cases sequentially (i.e. parallel=none, thread-count=1) though not in any particular order. In each case, I need to set up a complex environment, run the tests, then tear down the complex environment before moving on to the next test case where I will need to set up a new (but different and potentially conflicting) environment.  but my hope and expectation is that the entire test class is executed before proceeding to the next test case.  after a fair amount of experimentation and searching it appears to me that the @BeforeClass and @AfterClass methods may be executed at any arbitrary time providing that the time is indeed before or after the test methods within the class in question. as a result, the @AfterClass method may not execute (going by the log file) until potentially several test class executions later. causing my environments to conflict

 

am I incorrect in assuming that the @AfterClass method of one test class should execute before the @BeforeClass method of another test class?

 

how is it, when running in what appears to be be single threaded conditions, the test runner still seems to be intent on running the @AfterClasses in arbitrary order or at arbitrary times?

 

is there a way to configure testng such that each test class run to completion (with all associated @BeforeClass and @AfterClass methods) before proceeding to the next test class?

 

what is occurring now is that (for example) the @AfterClass methods are being invoked not at the end of the test class they are attached to, but at a later time, often in the middle of one of the subsequent test classes. sometimes just after the @BeforeClass method has been invoked for the next class. this is causing issues. as the before and after methods are counterparts. the test methods depend on things created by the @before.  is this really the intended operation for this feature?

 

the one viable (but annoying) option I have found is to place the @AfterClass actions into a test method and either set up a dependency chain or priority order which seems to be at odds with general good test practice. has anyone any other viable options?

 

or alternatively setup a testng.xml file that lists each test case a as a separate suite or something similar.  what I really want to know is whether the current behavior of the @BeforeClass and @AfterClass annotations is a feature or a bug.

 

cheers

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



 

--

Regards,

Ramniwas Vishwakarma

Cell No. :- 9977050509

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