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

  在編寫(xiě)測(cè)試的過(guò)程中,我們經(jīng)常遇到只想執(zhí)行個(gè)別或者某一部分/某一類(lèi)型的測(cè)試用例,這時(shí)我們可以使用TestNG的分組測(cè)試方法
  分組測(cè)試在配置時(shí),TestNG執(zhí)行的原則是:只保留小集合進(jìn)行執(zhí)行
  看代碼:
/**
*
* <p>
* Title: TestngGroups
* </p>
*
* <p>
* 對(duì)應(yīng)配置文件testng-groups.xml
* Description:使用groups進(jìn)行分組測(cè)試,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>

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