分组测试在配置时,TestNG执行的原则是:只保留最小集合进行执行
看代码:
/** * * <p> * Title: TestngGroups * </p> * * <p> * 对应配置文件testng-groups.xml * Description:使用groups进行分组测试,include和exclude的原则是保留最小集合, * </p> * * <p> * Company: * </p> * * @author : Dragon * * @date : 2014年10月13日 */ public class TestngGroups { @Test(groups = { "functest", "checkintest" }) public void testMethod1() { System.err.println("groups = { functest, checkintest }"); } @Test(groups = { "functest", "checkintest" }) public void testMethod2() { System.err.println("groups = { functest, checkintest }"); } @Test(groups = { "functest" }) public void testMethod3() { System.err.println("groups = { functest }"); } @Test(groups = { "checkintest" }) public void testMethod4() { System.err.println("groups = { checkintest }"); } } |
配置文件:testng-groups.xml
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd"> <suite name="framework_testng"> <test verbose="2" name="TestGroups"> <groups> <run> <include name="functest" /> <exclude name="checkintest" /> </run> </groups> <classes> <class name="com.dragon.testng.annotation.TestngGroups" /> </classes> </test> </suite> |