您的位置:軟件測試 > 開源軟件測試 > 開源單元測試工具 > TestNG
TestNG的組測試和組中組測試
作者:網(wǎng)絡(luò)轉(zhuǎn)載 發(fā)布時間:[ 2015/2/9 17:06:35 ] 推薦標簽:單元測試 TestNG

  在編寫測試的過程中,我們經(jīng)常遇到只想執(zhí)行個別或者某一部分/某一類型的測試用例,這時我們可以使用TestNG的分組測試方法
  分組測試在配置時,TestNG執(zhí)行的原則是:只保留小集合進行執(zhí)行
  看代碼:
/**
*
* <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>

上一頁12下一頁
軟件測試工具 | 聯(lián)系我們 | 投訴建議 | 誠聘英才 | 申請使用列表 | 網(wǎng)站地圖
滬ICP備07036474 2003-2017 版權(quán)所有 上海澤眾軟件科技有限公司 Shanghai ZeZhong Software Co.,Ltd