junit5-contingent

Allows for JUnit 5 tests to be contingent on the success of other tests

License

License

Categories

Categories

JUnit Unit Testing ORM Data
GroupId

GroupId

com.bnorm.junit5.contingent
ArtifactId

ArtifactId

junit5-contingent
Last Version

Last Version

0.1.0
Release Date

Release Date

Type

Type

pom.sha512
Description

Description

junit5-contingent
Allows for JUnit 5 tests to be contingent on the success of other tests
Project URL

Project URL

https://github.com/bnorm/junit5-contingent
Source Code Management

Source Code Management

https://github.com/bnorm/junit5-contingent

Download junit5-contingent

Dependencies

runtime (2)

Group / Artifact Type Version
org.jetbrains.kotlin : kotlin-stdlib-jdk8 jar 1.3.72
org.junit.jupiter : junit-jupiter-api jar 5.6.2

Project Modules

There are no modules declared in this project.

junit5-contingent

Maven Central

Allows for JUnit 5 tests to be contingent on the success of other tests.

Why?

Unit tests can fail for all sorts of reasons. Sometimes a multitude of failures can hide the unit test failures which expose the actual bug. If unit tests, which implicitly depended on functionality tested by other unit tests, failed early with a clear message what implicit dependency failed, then it could be easier pinpoint the actual problem. That's the problem this library is attempting to solve.

Also, I wanted to see if it could be done using JUnit 5 extensions. Yeah, mainly this reason.

Example

In the following example, tests required1 and required2 will be executed first. If none of them fail, then tests dependent1 and dependent2 will be allowed to run.

@ContingentExtension
class ContingentTests {
    @Test @Tag("required")
    public void required1() {}

    @Test @Tag("required")
    public void required2() {}

    @Test @Contingent("required")
    public void dependent1() {}

    @Test @Contingent("required")
    public void dependent2() {}
}

What's Next?

  • API: I'm not happy with the use of Tags to mark required tests. I don't like having to match raw strings for creating this link. The whole API layer could be greatly improved.

  • Cross-Class Linking: Right now unit tests are only linked if they exist in the same class. It would be great if they could be linked for all discovered unit tests.

Versions

Version
0.1.0