代码在TESTNG中分组
package testNG_annot;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
public class TestNG_grp1
{
@BeforeMethod
public void CarBM() {
System.out.println("CarBM");
}
*** // Created group car and Two wheeler//***
@Test(groups = { "Car" })
public void Sedan1() {
System.out.println("Test1-Verna");
}
@Test(groups = { "Car" })
public void Sedan2() {
System.out.println("Test2-BMW");
}
@Test(groups = { "TwoWheeler" })
public void Scooter1() {
System.out.println("Test3-ScootyPep");
}
@Test(groups = { "TwoWheeler" })
public void aScooter2() {
System.out.println("Test4-TVS");
}
}
suite.xml
<?xml version="1.0" encoding="UTF-8"?>
<suite name="grp11">
<test name="group1">
<gropus>
<run>
<include name="Car"/>
</run>
</gropus>
<classes>
<class name="testNG_annot.TestNG_grp1"/>
</classes>
</test>
</suite>
答案 0 :(得分:0)
将testng.xml文件格式化为以下格式。将其作为testng测试运行,您将运行测试。
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >
<suite name="Suite1">
<test name="Test" >
<classes>
<class name="testNG_annot.TestNG_grp1" />
</classes>
</test>
</suite>
答案 1 :(得分:0)
将其保存在xml
中 <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >
答案 2 :(得分:0)
您对群组标记的拼写错误。更改拼写并再次运行。
<groups>
<run>
<include name="Car"/>
</run>
</groups>