The dependsOnMethods
attribute of the @Test
annotation works fine when the test to be depended upon is in the same class as that of the test that has this annotation. But it does not work if the to-be-tested method and depended-upon method are in different classes. Example is as follows:
class c1 {
@Test
public void verifyConfig() {
//verify some test config parameters
}
}
class c2 {
@Test(dependsOnMethods={"c1.verifyConfig"})
public void dotest() {
//Actual test
}
}
Is there any way to get around this limitation? One easy way out is to create a test in class c2
that calls c1.verifyConfig()
. But this would be too much repetition.