Getting result in an improper sequence after updating testng from 6.8.8 to 6.14.2

23 views
Skip to first unread message

Denish Makwana

unread,
Apr 1, 2018, 1:09:28 PM4/1/18
to testng-users
The sequence of testng 6.8.8 class and methods:

before_class1
class1_method1
class1_method2
class1_method3
after_class1
before_class2
class2_method1
class2_method2
class2_method3
after_class2
before_class3
class3_method1
class3_method2
class3_method3
after_class3

The sequence of testng 6.14.2 class and methods:

before_class1
class1_method1
before_class2
class2_method1
before_class3
class3_method1
class1_method2
class2_method2
class3_method2
class1_method3
after_class1
class2_method3
after_class2
class3_method3
after_class3

I want output like 6.8.8 in 6.14.2 version..and also explain why this sequence change for new testng.. Need your help to understand this better.

For more information refer attached java file and testng.xml file . Run testng.xml file which I attached to this topic.
class1.java
class2.java
class3.java
testng.xml

Krishnan Mahadevan

unread,
Apr 1, 2018, 11:29:39 PM4/1/18
to testng...@googlegroups.com

Denish,

 

Lot of things have changed between those versions.

 

TestNG was updated in 6.10 as part of GITHUB-1156 changeset to start respecting the following ordering:

 

Hierarchy on order features (from less important to more important): groupByInstance, preserveOrder, priority, dependsOnGroups, dependsOnMethods

 

In your case, you have specified priority for each of the test methods in each of the test classes.

 

So TestNG is basically picking up @Test methods as below:

 

  1. Priority=0 methods [ class1_method1, class2_method1, class3_method1]. Since there’s a beforeclass included, all the beforeclass methods of all the 3 classes are getting invoked.
  2. Priority=1 methods [ class1_method2, class2_method2, class3_method2]
  3. Priority=2 methods[class1_method3, class2_method3, class3_method3] followed by executing the afterclass methods.

 

So if you need the order to be maintained as is, you would need to get rid of priority in all of your test methods. That would cause TestNG to respect preserve-order=true (which is set by default).

 

Hope that helps!

 

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/

Reply-To: <testng...@googlegroups.com>
Date: Sunday, April 1, 2018 at 10:39 PM
To: testng-users <testng...@googlegroups.com>
Subject: [testng-users] Getting result in an improper sequence after updating testng from 6.8.8 to 6.14.2

--
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
testng-users...@googlegroups.com.
To post to this group, send email to
testng...@googlegroups.com.
Visit this group at
https://groups.google.com/group/testng-users.
For more options, visit
https://groups.google.com/d/optout.

Denish Makwana

unread,
Apr 2, 2018, 12:05:45 PM4/2/18
to testng-users
Thank you Krishnan... I would really appreciate if you send one example for this.

To unsubscribe from this group and stop receiving emails from it, send an email to testng-users+unsubscribe@googlegroups.com.


To post to this group, send email to

Krishnan Mahadevan

unread,
Apr 2, 2018, 1:31:22 PM4/2/18
to testng...@googlegroups.com

What sample are you looking for?

You just need to remove off the “priority” attribute of your @Test annotation.

 

 

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/

Reply-To: <testng...@googlegroups.com>
Date: Monday, April 2, 2018 at 9:35 PM
To: testng-users <testng...@googlegroups.com>
Subject: Re: [testng-users] Getting result in an improper sequence after updating testng from 6.8.8 to 6.14.2

 

To unsubscribe from this group and stop receiving emails from it, send an email to testng-users...@googlegroups.com.


To post to this group, send email to

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 testng-users...@googlegroups.com.


To post to this group, send email to

Denish Makwana

unread,
Apr 2, 2018, 10:58:44 PM4/2/18
to testng...@googlegroups.com
Thank you Krishnan. It's working as expected. 🙂

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/dGnFiWX55ys/unsubscribe.
To unsubscribe from this group and all its topics, send an email to testng-users...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages