https://github.com/retest/recheck-junit-4-extension
Automatically administer lifecycle of JUnit 4 tests using recheck.
https://github.com/retest/recheck-junit-4-extension
junit-rule junit4 junit4-rules test-automation
Last synced: 5 months ago
JSON representation
Automatically administer lifecycle of JUnit 4 tests using recheck.
- Host: GitHub
- URL: https://github.com/retest/recheck-junit-4-extension
- Owner: retest
- License: agpl-3.0
- Created: 2019-09-28T15:57:16.000Z (over 6 years ago)
- Default Branch: develop
- Last Pushed: 2023-03-10T03:56:54.000Z (over 3 years ago)
- Last Synced: 2025-07-23T01:07:48.296Z (11 months ago)
- Topics: junit-rule, junit4, junit4-rules, test-automation
- Language: Java
- Homepage:
- Size: 215 KB
- Stars: 1
- Watchers: 2
- Forks: 1
- Open Issues: 7
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://github.com/retest/recheck-junit-4-extension/actions/workflows/build-project.yml)
[](https://mvnrepository.com/artifact/de.retest/recheck-junit-4-extension)
[](https://jitpack.io/#de.retest/recheck-junit-4-extension)
[](https://github.com/retest/recheck-junit-4-extension/blob/main/LICENSE)
[](https://github.com/retest/recheck-junit-4-extension/issues?q=is%3Aissue+is%3Aopen+label%3A%22help+wanted%22)
[](https://retest.de/)
[JUnit 4](https://junit.org/junit4/) extension for [recheck](https://github.com/retest/recheck). Automatic set up and tear down of tests using recheck.
## Features
* Calls `startTest` on given `RecheckLifecycle` object before each test.
* Calls `capTest` on given `RecheckLifecycle` object after each test.
* Calls `cap` on given `RecheckLifecycle` object after each test.
## Advantages
The extension automatically calls `startTest`, `capTest` and `cap`. So it is no longer required to call those methods manually. This reduces boilerplate code and ensures the life cycle within a test using recheck.
## Build tools
You can add ***recheck-junit-4-extension*** as an external dependency to your project. It is available in [Maven central](https://mvnrepository.com/artifact/de.retest/recheck-junit-4-extension) or via the [release-page](https://github.com/retest/recheck-junit-4-extension/releases), which allows you to include it into your favorite build tool.
For the current version, please refer to the release-page.
### Maven
```xml
de.retest
recheck-junit-4-extension
${LATEST_VERSION_FROM_ABOVE_LINK}
```
### Gradle
```gradle
compile 'de.retest:recheck-junit-4-extension:${LATEST_VERSION_FROM_ABOVE_LINK}'
```
## Usage
Recheck JUnit extension defines a [JUnit 4 Rule](https://github.com/junit-team/junit4/wiki/Rules). The rule needs to know the instance of the used `RecheckLifecycle` element. The instance can be given during construction or afterwards during setup. The following code demonstrates both ways.
### Recheck instance given during construction
```java
// Define RecheckLifecycle instance before Rule
private RecheckLifecycle re = new RecheckImpl();
// Let rule know which RecheckLifecycle instance should be administered
@Rule
public RecheckRule recheckRule = new RecheckRule(re);
```
### Recheck instance given during setup
```java
@Rule
public RecheckRule recheckRule = new RecheckRule();
private RecheckLifecycle re;
@Before
public void before() {
re = new RecheckImpl();
// Let rule know which RecheckLifecycle instance should be administered
recheckRule.use(re);
}
```
### Prerequisites
Requires [JUnit 4](https://mvnrepository.com/artifact/junit/junit). For [JUnit Jupiter](https://junit.org/junit5/) support look at [recheck extension for JUnit Jupiter](https://github.com/retest/recheck-junit-jupiter-extension).
## License
This project is licensed under the [AGPL license](LICENSE).