如果不优先考虑测试方法,则按字母顺序选择测试方法并执行。如果我们希望测试方法按照我们想要的顺序执行,那么我们需要提供优先级以及@Test 注解。
下面通过一个例子来理解:
package com.yiibai;
import org.testng.annotations.Test;
public class Test_methods
{
@Test(priority=2)
public void test1()
{
System.out.println("Test1");
}
@Test(priority=1)
public void test2()
{
System.out.print("Test2");
}
}