testng - 如何在XML中的组群中添加依赖关系

  显示原文与译文双语对照的内容

如何在 TestNG.This的XML组中添加依赖项的依赖项是我的XML


<test name="Test1">

<classes>
 <class name="test.TestNGTest1"/>
 <class name="test.TestNGTest2"/>
 <groups>
 <define name="abc">
 <include name="a"></include>
 </define>
 <define name="def">
 <include name="b"></include>
 </define>
 <run>
 <include name="def"></include>
 <include name="abc"></include>
 </run>
 </groups>
</classes>
</test>

我尝试在xml中添加组的依赖组。

时间: 作者:

有两个测试类:


public class TestNGTest1 {
 @Test(groups = {"a"})
 public void test1(){}
 @Test(groups = {"b"})
 public void test2(){}
 @Test(groups = {"c"})
 public void test3(){}
 @Test(groups = {"d"})
 public void test4(){}
 @Test(groups = {"e"})
 public void test5(){}
 @Test(groups = {"f"})
 public void test6(){}
}


public class TestNGTest2 {
 @Test(groups = {"a"})
 public void test1(){}
 @Test(groups = {"b"})
 public void test2(){}
 @Test(groups = {"c"})
 public void test3(){}
 @Test(groups = {"a"})
 public void test4(){}
 @Test(groups = {"b"})
 public void test5(){}
 @Test(groups = {"c"})
 public void test6(){}
}

组的依赖关系可以按以下方式定义:


<suite>
 <test name="Test1">
 <classes>
 <class name="test.TestNGTest1"/>
 <class name="test.TestNGTest2"/>
 <groups>
 <define name="abc">
 <include name="a"></include>
 <include name="b"></include>
 </define>
 <define name="def">
 <include name="d"></include>
 <include name="e"></include>
 </define>
 <dependencies>
 <group name="abc" depends-on="def"/>
 </dependencies>
 <run>
 <include name="def"></include>
 <include name="abc"></include>
 </run>
 </groups>
 </classes>
 </test>
</suite>

作者:

你可以使用依赖和依赖标记( 如 ) 在xml中指定组依赖项。

...