@Test(priority = x)設置測試用例執行優先級。
x默認為0,0的優先級最高,0>1>2>3...
import org.testng.annotations.Test; public class PriorityTest { @Test(priority = 3) public void priorityTest1(){ System.out.println("priorityTest1 運行"); } @Test(priority = 2) public void priorityTest2(){ System.out.println("priorityTest2 運行"); } @Test(priority = 1) public void priorityTest3(){ System.out.println("priorityTest3 運行"); } @Test(priority = 0) public void priorityTest4(){ System.out.println("priorityTest4 運行"); } }
執行結果為:

