testng.xml 中的方法依赖
method dependency in testng.xml
我正在尝试在 testng.xml 中添加方法依赖性,但这似乎不起作用。有人可以建议,我在这里缺少什么。
<suite name="Test Suite for End To End">
<test name="AUT_E2E_01">
<parameter name="browser" value="Chrome" />
<classes>
<class name="com.myunit.regressiontests">
<methods>
<include name="AutTC03" />
<include name="AutTC11" dependsOnMethods="AutTC03" />
</methods>
</class>
</classes>
</test>
</suite>
那里不允许属性 dependsOnMethods
(请参阅 TestNG DTD)。
以下是 TestNG Documentation - 5.7 - Dependencies 的一些摘录(为方便起见添加了链接):
TestNG allows you to specify dependencies either with annotations or in XML.
5.7.1 - Dependencies with annotations
You can use the attributes dependsOnMethods
or dependsOnGroups
, found on the @Test
annotation.
Alternatively, you can specify your group dependencies in the testng.xml
file.
即您可以在 Java 和 XML 中定义“组”依赖关系,但只能在 Java 中定义“方法”依赖关系(使用 @Test
注释)。
但是,即使您无法在 XML 中定义“方法”依赖项,您也可以将方法分组以供使用。
例如以下假设您已将 AutTC03
和 AutTC11
分别放入名为 AutTC03-Group
和 AutTC11-Group
的 test groups 中:
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >
<suite name="Test Suite for End To End">
<test name="AUT_E2E_01">
<parameter name="browser" value="Chrome" />
<classes>
<class name="com.myunit.regressiontests">
<methods>
<include name="AutTC03" />
<include name="AutTC11" dependsOnMethods="AutTC03" />
</methods>
</class>
</classes>
<groups>
<dependencies>
<group name="AutTC11-Group" depends-on="AutTC03-Group" />
</dependencies>
</groups>
</test>
</suite>
我正在尝试在 testng.xml 中添加方法依赖性,但这似乎不起作用。有人可以建议,我在这里缺少什么。
<suite name="Test Suite for End To End">
<test name="AUT_E2E_01">
<parameter name="browser" value="Chrome" />
<classes>
<class name="com.myunit.regressiontests">
<methods>
<include name="AutTC03" />
<include name="AutTC11" dependsOnMethods="AutTC03" />
</methods>
</class>
</classes>
</test>
</suite>
那里不允许属性 dependsOnMethods
(请参阅 TestNG DTD)。
以下是 TestNG Documentation - 5.7 - Dependencies 的一些摘录(为方便起见添加了链接):
TestNG allows you to specify dependencies either with annotations or in XML.
5.7.1 - Dependencies with annotations
You can use the attributes
dependsOnMethods
ordependsOnGroups
, found on the@Test
annotation.Alternatively, you can specify your group dependencies in the
testng.xml
file.
即您可以在 Java 和 XML 中定义“组”依赖关系,但只能在 Java 中定义“方法”依赖关系(使用 @Test
注释)。
但是,即使您无法在 XML 中定义“方法”依赖项,您也可以将方法分组以供使用。
例如以下假设您已将 AutTC03
和 AutTC11
分别放入名为 AutTC03-Group
和 AutTC11-Group
的 test groups 中:
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >
<suite name="Test Suite for End To End">
<test name="AUT_E2E_01">
<parameter name="browser" value="Chrome" />
<classes>
<class name="com.myunit.regressiontests">
<methods>
<include name="AutTC03" />
<include name="AutTC11" dependsOnMethods="AutTC03" />
</methods>
</class>
</classes>
<groups>
<dependencies>
<group name="AutTC11-Group" depends-on="AutTC03-Group" />
</dependencies>
</groups>
</test>
</suite>