2
votes

Using java and testNG I have two tests in two different classes, test1.class and test2.class, and a base.class that contains most of the methods:

public class BaseTest {

@Test
public void step1() {

}

@Test(dependsOnMethods="step1")
public void step2() {

}

@Test(dependsOnMethods="step3")
public void step4() {

}
}

public class Test1() extends BaseTest {
@Test(dependsOnMethods="step2")
public void step3() {

}
}

I then runt a testng-test on test1.class but that wont work, it says "step4 is depending on method public void step3(), which is not annotated with @Test or not included"

I guess this is the wrong way to do this, but I can't figure out a better way. Any help is much appreciated.

1

1 Answers

2
votes

It seems a little counterintuitive. Without understanding what's going on in your tests, perhaps step3() should actually be an abstract method implemented in subclasses, and not an annotated test.

That way step3() will always get run since it's called from the base class and implemented in the subclasses.