Rule support in Jupiter

As described before, Jupiter does not support JUnit 4 rules natively. Nevertheless, the JUnit 5 team realized that JUnit 4 rules are widely adopted in many test codebases nowadays. In order to provide a seamless migration from JUnit 4 to JUnit 5, the JUnit 5 team implemented the junit-jupiter-migrationsupport module. If this module is going to be used in a project, the module dependency should be imported. Examples for Maven are shown here:

<dependency>   <groupId>org.junit.jupiter</groupId>   <artifactId>junit-jupiter-migrationsupport</artifactId>   <version>${junit.jupiter.version}</version>   <scope>test</scope></dependency>

The Gradle declaration for this dependency is like this:

dependencies { testCompile("org.junit.jupiter:junit-jupiter- ...

Get Mastering Software Testing with JUnit 5 now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.