Can we set priority at Class level in TestNg?

62 views Asked by At
@Test(priority=2)

public class PositiveTests {
 
    public void loginTest() {
}
@Test(priority=1)

public class NegativeTests {

    public void negativeLoginTest() {
}

TestNg.xml

<classes>
            <class name="com.herokuapp.theinternet.PositiveTests" />
            <class name="com.herokuapp.theinternet.NegativeTests">
</classes>

-->> Will the priority work here? Which class will run first? Positive Test or Negative Test?

1

There are 1 answers

0
murali selenium On

priority works for @Test methods inside class.

To run classes in specified order, we need to use preserver-order as'true'

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