同时通过XML.But直接运行的代码时,其工作的罚款
问题描述:
守则TestNG中同时通过XML.But直接运行的代码时,其工作的罚款
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>
答
你的拼写组标签是错误的。更改拼写并重新运行。
<groups>
<run>
<include name="Car"/>
</run>
</groups>
答
分组形式TestNG的运行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>
+0
组标记拼写错误。所以testng无法获取该类文件。改变它,然后再试一次 –
答
在你的XML保持这个顶部
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >
变化拼写为基。这可能是你错误的原因。 – shank087
引用这个问题,它会解决你的查询。 http://*.com/questions/41844611/depends-on-groups-method-is-not-executing-prorperly-from-another-class-file –