Is there way to span dependencies across Tests in TestNG?
I'm on TestNG 6.8.5. Is there a way to span either dependsOnGroups or
dependsOnMethods across Tests, rather than just within a single Test?
I have a Suite configured like this with two Tests and a bunch of other
Tests between them:
<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>
My test class has methods configured like this:
@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)
}
But when I run the suite, the dependsOnGroups annotation fails with an
error like this:
[ERROR] org.testng.TestNGException:
[ERROR] DependencyMap::Method .... DeviceMgmtTest depends on nonexistent
group "setup"
Maybe I'm not understanding something correctly about how to configure my
Suite (I'm very new to TestNG), but separating these areas of concern out
into separate Tests makes sense to me.
Thanks for any guidance or suggestions!
No comments:
Post a Comment