package com.course.testng.groups;

import org.testng.annotations.Test;

@Test(groups = "stu")
public class GroupsOneClass1 {
public void student1(){
System.out.println("Class中的student1运行..................");
}
public void student2(){
System.out.println("Class中的student2运行..................");
}
}
package com.course.testng.groups;

import org.testng.annotations.Test;

@Test(groups = "stu")
public class GroupsOneClass2 {
public void student1(){
System.out.println("Class2中的student1运行..................");
}
public void student2(){
System.out.println("Class2中的student2运行..................");
}
}
package com.course.testng.groups;

import org.testng.annotations.Test;

@Test(groups = "teah")
public class GroupsOneClass3 {
public void teacher1(){
System.out.println("Class3中的teacher1运行..................");
}
public void teacher2(){
System.out.println("Class3中的teacher2运行..................");
}
}
<?xml version="1.0" encoding="utf-8" ?>
<suite name = "test">
<test name = "RunAll">
<classes>
<class name = "com.course.testng.groups.GroupsOneClass1"/>
<class name = "com.course.testng.groups.GroupsOneClass2"/>
<class name = "com.course.testng.groups.GroupsOneClass3"/>
</classes>
</test> <test name = "RunStu">
<groups>
<run>
<include name = "stu"/>
</run>
</groups>
<classes>
<class name = "com.course.testng.groups.GroupsOneClass1"/>
<class name = "com.course.testng.groups.GroupsOneClass2"/>
<class name = "com.course.testng.groups.GroupsOneClass3"/>
</classes>
</test>
</suite>

TestNG(八) 类分组测试-LMLPHP

05-20 17:13