package test;
import org.testng.annotations.Test;
public class Day3 {
@Test
public void webLoginCarLoan() {
System.out.println("WebLoginCarLoan");
}
@Test
public void mobileLoginCarLoan() {
System.out.println("MobileLoginCarLoan");
}
@Test
public void mobileSignoutCarLoan() {
System.out.println("MobileSignoutCarLoan");
}
@Test(dependsOnMethods = { "webLoginCarLoan" })
public void apiCarLoan() {
System.out.println("LoginAPICarLoan");
}
}
输出:
MobileLoginCarLoan
WebLoginCarLoan
MobileSignoutCarLoan
LoginAPICarLoan
为什么在输出中,WebLoginCarLoan优先于MobileSignoutCarLoan?
答案 0 :(得分:0)
TestNG不能按照类中指出的顺序执行测试。如果您认为需要按指定的顺序执行测试/ @ Test方法,那么请使用优先级
@Test(priority=1)
还如Mark所指出的:“我认为dependsOnMethods将确保webLoginCarLoan在apiCarLoan之前执行,但不会在其本身之后立即执行”