TestNG控制case运行顺序
作者:
网络转载 发布时间:
[ 2015/9/30 14:15:48 ] 推荐标签:
TestNG
3.例如下代码
package yycuser13.test.testcase;
import org.testng.annotations.Test;
import org.testng.annotations.Test;
public class Test1{
@Test(priority=3)
public void login(){
System.out.println("my name id login");
}
@Test(priority=2)
public void login1(){
System.out.println("my name id login1");
}
@Test(priority=1)
public void logout(){
System.out.println("my name id logout");
}
@Test(priority=4)
public void logout1(){
System.out.println("my name id logout1");
}
}
运行结果为:
my name id logout
my name id login1
my name id login
my name id logout1
===============================================
Suite
Total tests run: 4, Failures: 0, Skips: 0
4.例如下代码 加入了 dependsOnGroups
package yycuser13.test.testcase;
import org.testng.annotations.Test;
public class Test1{
@Test(groups={"login"},dependsOnGroups={"logout"})
public void login(){
System.out.println("my name id login");
}
@Test(groups={"login"},dependsOnGroups={"logout"})
public void login1(){
System.out.println("my name id login1");
}
@Test(groups={"logout"})
public void logout(){
System.out.println("my name id logout");
}
@Test(groups={"logout"})
public void logout1(){
System.out.println("my name id logout1");
}
}
运行结果为:
my name id logout
my name id logout1
my name id login
my name id login1
PASSED: logout
PASSED: logout1
PASSED: login
PASSED: login1
===============================================
Default test
Tests run: 4, Failures: 0, Skips: 0
5.例如下代码 使用dependsOnMethods
package yycuser13.test.testcase;
import org.testng.annotations.Test;
public class Test1{
@Test(dependsOnMethods={"login1"})
public void login(){
System.out.println("my name id login");
}
@Test(dependsOnMethods={"logout"})
public void login1(){
System.out.println("my name id login1");
}
@Test
public void logout(){
System.out.println("my name id logout");
}
@Test(dependsOnMethods={"login"})
public void logout1(){
System.out.println("my name id logout1");
}
}
运行结果为:
my name id logout
my name id login1
my name id login
my name id logout1
PASSED: logout
PASSED: login1
PASSED: login
PASSED: logout1
===============================================
Default test
Tests run: 4, Failures: 0, Skips: 0