Priority support for all testNg annotaion

104 views
Skip to first unread message

Martin Aldrin

unread,
Sep 29, 2017, 8:04:37 AM9/29/17
to testng-dev
Hi,

One feature that I really missing in TestNg is the possibility to set priority for the before and after methods.
Today we using an ugly workaround to be able to run these methods in wanted order by naming the methods in alphabetical order. But this is a ugly solution.


The reason why we want to have this is because we using TestNg for system verification. The normal time execution is between 1 hour up to 72 hours, and therefor it is very important to control in which order we want to run our pre/post checks to get as early feedback as possible without stop the execution. Most of our pre/post checks are not allowed to stop the execution because we want to collect as much information as possible for long night/weekend runs.


So my question is if such feature would be acceptable, we could help out with the contribution the implementation. 



/Martin


Krishnan Mahadevan

unread,
Sep 29, 2017, 9:13:43 AM9/29/17
to testn...@googlegroups.com

Martin,

 

I would be curious to know why would you have multiple before and after methods?

 

For e.g., if you are running into a situation wherein you need to have multiple @BeforeSuite/@AfterSuite, then you could easily convert them into a listener format and perhaps even control the order of execution of the listeners.

 

Can you please help add more context around this ?

 

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/

--
You received this message because you are subscribed to the Google Groups "testng-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to testng-dev+...@googlegroups.com.
To post to this group, send email to testn...@googlegroups.com.
Visit this group at https://groups.google.com/group/testng-dev.
For more options, visit https://groups.google.com/d/optout.

Martin Aldrin

unread,
Oct 3, 2017, 1:51:45 AM10/3/17
to testng-dev
Hi Krishnan,

The reason why we want to be able to use so many methods is because we want to divide each pre/ post check so we get verdict for each of them. 
Also to be able to use the TestNg groups to be able to enable/disable checks. 
It is mainly Before/After Test and Before/Aftter Method that we have multiple methods of.
Separating them into several methods also gives a good way of separating the logs which can be huge.

We have the possibility to specify all our checks in xml as well using a listener, but that does not give us the same possibilities as we get when we writing the tests in code, so in different use cases we have different needs 


Here is an example how a test case, where we lock a device in one test case and unlock it in other, we want to run all the pre checks once, and the post checks after both lock and unlock. Today we need to name the methods in alphabetical order to run all pre/post checks in wanted order.

@BeforeTest
public void checkAlarm){}

@BeforeTest
public void checkError){}

@Test
public void lockDevice(){}

@Test
public void unlockDevice(){}

@AfterMethod
public void checkAlarm){}
 
@AfterMethod
public void checkError){}
Reply all
Reply to author
Forward
0 new messages