How to run a Selenium two diffrent file in order

Viewed 25

**enter image description hereI have two different files in a same package named as UserManagement and VerifyLogin. In this case if i try to run this project in TestNg Server it runs the UserMangement as first but I need VerifyLogin to run as first. What is the solution? **

I Priorities the Test Case as 1,2,3,4 in VerifyLogin Class file and Test case 5 in UserManagement in next file but it runs the file Usermanagement as first file and throwing error as nullpointException

I need to run VerifyLogin as first file

1 Answers

Create a testNG xml like below , replace the class names with your class files. We have added a parameter in this xml called "preserve-order" which will preserve the Test execution order in class when set to true To run using XMl if you are using eclipse , you need to install TestNG plugin, right click on the xml file and run as TestNgSuite

<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="Preserve order test runs">
  <test name="Regression 1" preserve-order="true">
    <classes>
      <class name="com.pack.preserve.ClassOne"/>
      <class name="com.pack.preserve.ClassTwo"/>
    </classes>
  </test>
</suite>
Related