How to run test methods in specific order in TestNG ?

Hi,

My xml script is executing methods in alphabetical order, I wanted to execute my tests in my own order

Can anyone suggest How to run test methods in specific order in  TestNG  xml?

Aruna Train Asked on March 5, 2015 in Selenium WebDriver.
Add Comment
2 Answer(s)

Aruna, try using the priority attribute to your @Test annotation like this. @Test(priority=1) .  Choose the priority in an order starting from 1 and test will be executed from 1 2 3 to the max number.

Virender

Virender Singh Professor Answered on March 6, 2015.

Virender, This really worked..

Thank you

on March 9, 2015.
Add Comment

Hi Aruna,

If you want to run testng.xml based on your preference then add below code into testng.xml

<test name="Regression1" preserve-order="false">

Refer below tutorial for more details

http://www.learn-automation.com

Mukesh_50 Default Answered on March 5, 2015.

Hi,

I have added the above suggested line in my xml, but it doesn’t worked :( .

Regards,
Aruna.

on March 9, 2015.
Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.