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.bar() and YTest.testBar() 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.testBar(). 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 XTest { @Test @DependsOn(method=org.example.tests.YTest#testBar) public void testFoo() { // Assert.something(); } }
The junit-jupiter-api dependency provides the public API that allows us to write tests and extensions which use JUnit 5. The junit-jupiter-engine dependency ensures that the Maven Surefire Plugin can run tests which use JUnit 5.
Said libraries provide their own test runner, which supports their dependency mechanism. And both can be used alongside JUnit (without need to rewrite existing classes).
So, what is a unit testing dependency? It's a dependency that you must set up in the test before you can exercise the system under test. Dependencies can be explicit, like in the example above, but they also can be implicit.
JExample and TestNG have something like that.
I don't know how useful it is, but if you try it, please come back to tell us whether it was useful.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With