testng.xml中groups标签使用

XML配置如下:

<?xml version="1.0" encoding="UTF-8"?>

<suite name="suiteName">

    <test name="postTest">   //name在测试报告中会有体现
    
        <groups>   //groups标签必须在test标签里面
            <run>
                <include name = "groupName1"/>  //组名为groupName1(必须在代码中真实存在),运行
                <exclude name = "groupName2" />  //组名为groupName2,不运行
            </run>
        </groups>
        
        <classes>
            <class name = "路径+将要测试的class名称" />  //在哪个类中执行以上groups
        </classes>
    </test>

</suite>

Class用例配置简单示例如下:

public class ClassName {  //classname与<classes>标签中的name相对应
     
     @Test(groups = {"groupname"})  // groupname与xml中的groupname相对应
     public void Method1{
         
     }
    
}

 详细资料参考:

https://www.ibm.com/developerworks/cn/java/j-testng/index.html

https://www.ibm.com/developerworks/cn/java/j-test-ng/

posted @ 2017-12-05 17:56  yuxuefeng  阅读(425)  评论(0编辑  收藏  举报