一、用一个class里面不同test方法执行顺序设置
使用priority
来控制test方法的执行顺序,数值越小,优先级越高。
package test;
import org.testng.annotations.Test;
public class test_demo1 {
@Test(priority = 2)
public void test1() {
System.out.println("jacoco test1");
}
@Test(priority = 1)
public void test2() {
System.out.println("jacoco test2");
}
}
以上,case执行结果:优先执行test2,再执行test1
二、用一个package下面不同class文件执行顺序设置
如下图,设置test_demo1、test_demo2的执行顺序为:test_demo2 --> test_demo1
方法: