Reputation: 85
TestNG mixes tests from different classes when executing. Each class has a few tests. And instead of executing like this:
FirstTestClass thirdTest
SecondTestClass firstTest
It executes like this, mixing tests from each class:
This is my XML:
<suite name="Mobile App Automation" verbose="1">
<test name="Android">
<parameter name="OS" value="android"/>
<parameter name="remote" value="true"/>
<classes>
<class name="Test.FirstTestClass"/>
<class name="Test.SecondTestClass"/>
</classes>
</test>
All my tests have the priority parameter set. But it's supposed to affect only tests inside a class, not EVERY test of the project, which is happening now.
Any hints?
Upvotes: 2
Views: 987
Reputation: 4507
When your code runs from the testng file, all the test cases with priority=0 run first then run the tests with priority=1 and so on. So if you want the test cases to run in a particular order you need to remove the priorities from the tests from all the classes.
And in the testng file you can also add preserve-order="true" along with the <suite name="Mobile App Automation" verbose="1">
line, then all the tests mentioned in the first class will run first and then the tests in the second class, but still if there is priorities set within the classes, the order of the tests will run according to the priorities.
So you need to remove the priorities first and then you can use preserve-order="true"
to maintain the order of execution of the classes.
Upvotes: 1