Migration from JUnit 4 to JUnit 5
JUnit 5 does not support JUnit 4 features, such as Rules and Runners, natively. Nevertheless, JUnit 5 provides a gentle migration path via the JUnit Vintage test engine, which allows us to execute legacy test cases (including JUnit 4 but also JUnit 3) on the top of the JUnit Platform.
The following table can be used to summarize the main differences between JUnit 4 and 5:
Feature | JUnit 4 | JUnit 5 |
Annotations package |
|
|
Declaring a test |
|
|
Setup for all tests |
|
|
Setup per test |
|
|
Tear down per test |
|
|
Tear down for all tests |
|
|
Tagging and filtering |
|
|
Disable a test method or class |
|
|
Nested tests | NA |
|
Repeated test | Using custom rule |
|
Dynamic tests | NA |
|
Test templates | NA |
|
Runners |
| This feature is superseded by the extension model ( |
Rules |
| This feature is superseded by the extension model... |