Skip to content

Automatically administer lifecycle of JUnit 4 tests using recheck.

License

Notifications You must be signed in to change notification settings

retest/recheck-junit-4-extension

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Build Status Latest recheck-junit-4-extension on Maven Central Latest recheck-junit-4-extension releases on JitPack license PRs welcome code with hearth by retest

JUnit 4 extension for 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 or via the release-page, which allows you to include it into your favorite build tool.

For the current version, please refer to the release-page.

Maven

<dependency>
	<groupId>de.retest</groupId>
	<artifactId>recheck-junit-4-extension</artifactId>
	<version>${LATEST_VERSION_FROM_ABOVE_LINK}</version>
</dependency>

Gradle

compile 'de.retest:recheck-junit-4-extension:${LATEST_VERSION_FROM_ABOVE_LINK}'

Usage

Recheck JUnit extension defines a JUnit 4 Rule. 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

// 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

@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. For JUnit Jupiter support look at recheck extension for JUnit Jupiter.

License

This project is licensed under the AGPL license.