Categories

1 Answer

Aug 22, 2019

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

Click here to read more about Selenium
Click here to read more about Insurance

Related questions

Madanswer
Aug 22, 2019 in Selenium
Aug 22, 2019 in Selenium
Aug 21, 2019 in Selenium
...