如何从TestNG中的测试用例集合中合并和删除测试方法?
示例
Testngxml文件。
<?xml version = "1.0" encoding = "UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >
<suite name = "Tutorialspoint Test ">
<test name = "Test Cycle">
<groups>
<run>
<include name = "Smoke"/>
<exclude name = "CodingModule"/>
</run>
</groups>
<classes>
<class name = "TestRegularExpression" />
</classes>
</test>
</suite>testNGxml具有要包含的Smoke组和要从执行中排除的CodingModule组。
示例
@Test(groups={"Smoke"})
public void ContactDetails(){
System.out.println(“Contact details verification is successful”);
}
@Test(groups={"CodingModule"})
public void verifyInvoice(){
System.out.println(“Invoice verification is successful”);
}在Java类文件中,组用于查明测试方法。组(例如Smoke)的测试方法将添加到运行中,而CodingModule将从执行中排除。因此,ContactDetails()测试方法将运行,但verifyInvoice()将被排除在执行之外。