Skip to content

JUnit5 extensions library including JUnit5 equivalents of some of the common JUnit4 rules: ExpectedException, TemporaryFolder etc

License

Notifications You must be signed in to change notification settings

istarwyh/junit-extensions

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

93 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

JUnit Extensions

Build Status Coverage Status Scrutinizer Javadoc Maven Central GitHub Release

With thanks and appreciation to the authors of JUnit5.

There have been discussions amongst the JUnit community (see this and this) about providing official JUnit Jupiter Extensions for the most popular JUnit4 Rules. The upshot of these discussions seems to be enabling limited support for JUnit4 rules on JUnit5. For anyone who would rather move entirely to JUnit5, this library provides JUnit5 implementations of some of the commonly used JUnit4 rules.

Documentation

Extensions

  • BenchmarkExtension: publishes test elapsed time to the console, by default, but also available via the EngineExecutionListener for customised reporting.
  • ExpectedExceptionExtension: allows you to run a test method with an expected exception and (optionally) exception message, delegating responsibility for making the assertion to the extension.
  • RandomBeansExtension: allows you to inject random instances of classes into your tests, useful when you need a class instance to test with but you don't care about its contents.
  • SystemPropertyExtension: allows you to set system properties before test execution and reverts these changes on test completion.
  • TemporaryFolderExtension: allows you to create temporary files and directories in your test, any such files or directories created in your tests are removed for you when the tests complete.
  • TestNameExtension: allows you to use the name of the currently executing test within your test cases.
  • WatcherExtension: logs test execution flow including entry, exit and elapsed time in milliseconds.

Using JUnit-Extensions

The junit-extensions library is available on Maven Central:

Maven

<dependency>
    <groupId>io.github.glytching</groupId>
    <artifactId>junit-extensions</artifactId>
    <version>2.6.0</version>
    <scope>test</scope>
</dependency>

Gradle

testCompile 'io.github.glytching:junit-extensions:2.6.0'

Building JUnit-Extensions

$ git clone https://github.com/glytching/junit-extensions.git
$ cd junit-extensions
$ mvn clean install

This will compile and run all automated tests and install the library in your local Maven repository.

Note: the code is formatted using the Google Code Formatter.

License

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.

You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.###

About

JUnit5 extensions library including JUnit5 equivalents of some of the common JUnit4 rules: ExpectedException, TemporaryFolder etc

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Java 100.0%