How can I specifiy JUnit test dependencies?
- by Egon Willighagen
Our toolkit has over 15000 JUnit tests, and many tests are known to fail if some other test fails. For example, if the method X.foo() uses functionality from Y.foo() and YTest.testFoo() fails, then XTest.testFoo() will fail too. Obviously, XTest.testFoo() can also fail because of problems specific to X.foo().
While this is fine and I still want both tests run, it would be nice if one could annotate a test dependency with XTest.testFoo() pointing to YTest.testFoo(). This way, one could immediately see what functionality used by X.foo() is also failing, and what not.
Is there such annotation available in JUnit or elsewhere? Something like:
public YTests {
@Test
@DependsOn(method=org.example.tests.YTest#testFoo)
public void testFoo() {
// Assert.something();
}
}