1. 忽略测试
@Test(enabled=false) false是忽略测试,true是不忽略
2.分组测试
@Test(groups = "stu")
public class GroupsOnClass1 {
public void stu1(){
System.out.println("GroupsOnClass1中的stu1111运行");
}
//在class1,class2,class3这3个类中选择组名是“stu”的组进行测试
<test name="onlyRunStu">
<groups>
<run>
<include name="stu"/>
</run>
</groups>
<classes>
<class name="com.course.testng.groups.GroupsOnClass1"/>
<class name="com.course.testng.groups.GroupsOnClass2"/>
<class name="com.course.testng.groups.GroupsOnClass3"/>
</classes>
</test>
3.依赖测试 如test1失败或者报错,test2会skip
@Test
public void test1(){
System.out.println("test1 run");
throw new RuntimeException();
}
@Test(dependsOnMethods = {"test1"})
public void test2(){
System.out.println("test2 run");
}