How can I specifiy JUnit test dependencies?

Posted by Egon Willighagen on Stack Overflow See other posts from Stack Overflow or by Egon Willighagen
Published on 2010-04-06T12:06:40Z Indexed on 2010/04/06 12:13 UTC
Read the original article Hit count: 327

Filed under:
|
|

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();
  }

}

© Stack Overflow or respective owner

Related posts about java

Related posts about unit-testing