https://github.com/bnorm/junit5-contingent
JUnit5 extension for making unit tests contingent on other unit test success
https://github.com/bnorm/junit5-contingent
Last synced: about 1 year ago
JSON representation
JUnit5 extension for making unit tests contingent on other unit test success
- Host: GitHub
- URL: https://github.com/bnorm/junit5-contingent
- Owner: bnorm
- License: apache-2.0
- Created: 2020-08-05T14:29:50.000Z (almost 6 years ago)
- Default Branch: main
- Last Pushed: 2020-08-09T17:29:12.000Z (almost 6 years ago)
- Last Synced: 2025-01-25T13:22:20.854Z (over 1 year ago)
- Language: Kotlin
- Size: 82 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# junit5-contingent
[](https://maven-badges.herokuapp.com/maven-central/com.bnorm.junit5.contingent/junit5-contingent)
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.
```java
@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.