How to run test cases sequentially using testng.xml

2,791 views
Skip to first unread message

Raju Arelli

unread,
May 18, 2016, 3:03:31 AM5/18/16
to testng-users

I have written several test classes to test a web application using TestNG. Each and every test classes are independent.(I use Java,TestNG)

I have defined my test classes in the testng.xml as below.


<test verbose="2" name="Default test" parallel="false" >


<classes>


<class name="bvtTestCases.TC001_TestCase1"  />

<class name="bvtTestCases.TC002_TestCase2" />

<class name="bvtTestCases.TC003_TestCase3" />

<class name="bvtTestCases.TC004_TestCase4" />


</classes>


But the problem is when i run testng.xml , it runs all test classes same time(parallely).As there are 4test classes then it opens 4 web browser instances same time and try to run every test classes same time.


But What I need is to run first class first and when it is completed then start running the second class. 

can any one help me to do this? I really appreciate the help


Thanks,
Raju

⇜Krishnan Mahadevan⇝

unread,
May 18, 2016, 3:57:04 AM5/18/16
to testng...@googlegroups.com
The easiest way of doing this would be to add preserve-order=true [ This attribute has a relevance only when parallel is set to "false" ]. Additionally you can confine the number of threads by setting thread-count to "1" 

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

Raju Arelli

unread,
May 18, 2016, 7:31:14 AM5/18/16
to testng...@googlegroups.com
It's not working Krishnan. I kept like below as you said.

<test verbose="2" name="Default test" parallel="false" preserve-order="true" thread-count="1" >


<classes>


<class name="bvtTestCases.TC001_TestCase1"  />

<class name="bvtTestCases.TC002_TestCase2" />

<class name="bvtTestCases.TC003_TestCase3" />

<class name="bvtTestCases.TC004_TestCase4" />


</classes>

⇜Krishnan Mahadevan⇝

unread,
May 18, 2016, 7:43:43 AM5/18/16
to testng...@googlegroups.com
In that case, you would need to show us the code for all of your test classes [ Trimmed down versions which can be executed would do ]

That way we can execute your reproducible sample code to recreate the problem and tell you what is going wrong.

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/

⇜Krishnan Mahadevan⇝

unread,
May 18, 2016, 7:44:55 AM5/18/16
to testng...@googlegroups.com
And oh btw, can you also try adding the below to your <suite> tag ?

parallel="false" preserve-order="true" thread-count="1"

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 all
Reply to author
Forward
0 new messages