私はTestNG 6.8.5を使用しています。単一のテスト内だけでなく、複数のテストにまたがる dependsOnGroups または dependsOnMethods にまたがる方法はありますか?
私は、2 つのテストとそれらの間の他のテストの束で、このように構成されたスイートを持っています。
<suite name="ConfigurationSuite">
<test name="DeviceMgmtTest_Setup" >
<classes>
<class name="com.yay.DeviceMgmtTest">
<methods>
<include name="createDevice" />
<include name="discoverDevice" />
</methods>
</class>
</classes>
</test>
<!-- A whole bunch of other very sequential
and long-running tests go here... -->
<test name="DeviceMgmtTest_TearDown" >
<classes>
<class name="com.yay.DeviceMgmtTest">
<methods>
<include name="deleteDevice" />
</methods>
</class>
</classes>
</test>
</suite>
私のテストクラスには、次のように構成されたメソッドがあります。
@Test(groups = { "setup" })
public void createDevice() {
// do something
}
@Test(groups = { "setup" })
public void discoverDevice() {
// do something
}
@Test(groups = { "tearDown" }, dependsOnGroups = { "setup" })
public void deleteDevice() {
// When TestNG reaches this method I get a
// group "setup" does not exist type exception (see below)
}
しかし、スイートを実行すると、dependsOnGroups アノテーションが次のようなエラーで失敗します。
[ERROR] org.testng.TestNGException:
[ERROR] DependencyMap::Method .... DeviceMgmtTest depends on nonexistent group "setup"
スイートの構成方法について正しく理解していない可能性があります (私は TestNG を初めて使用します) が、これらの関心領域を個別のテストに分けることは理にかなっています。
ガイダンスや提案をありがとう!
編集: 私が検討している解決策の 1 つは、TestNG ITestContext を取得して親スイートに移動し、前のテストのステータスを確認することです。もっと洗練された TestNG 規則があるかもしれないと思っただけです。