in Selenium by
Q:
How to set test case priority in TestNG?

► Click here to show 1 Answer

0 votes
by

We use priority attribute to the @Test annotations. In case priority is not set then the test scripts execute in alphabetical order.

package TestNG;

import org.testng.annotations.*;

public class PriorityTestCase{

@Test(priority=0)

public void testCase1() {  

system.out.println("Test Case 1");

}

@Test(priority=1)

public void testCase2() {  

system.out.println("Test Case 2");

}

}

1

2

3

4

5

6

7

8

9

10

11

12

package TestNG;

import org.testng.annotations.*;

public class PriorityTestCase{

 @Test(priority=0)

 public void testCase1() {  

 system.out.println("Test Case 1");

 }

 @Test(priority=1)

 public void testCase2() { 

 system.out.println("Test Case 2");

 }

}

Output:

Test Case 1

Test Case 2

1

2

Test Case 1

Test Case 2

Selenium
Learn More with Madanswer

Related questions

+1 vote
asked Aug 22, 2019 in Selenium by john ganales
...