📄️ Migrate to JUnit 5
JUnit 5 (also known as JUnit Jupiter) was released in 2017 and introduced significant improvements over JUnit 4.
📄️ Migrate to JUnit 6
JUnit 6 was released in 2025. The main change is a baseline requirement of Java 17, which affects tests using conditional execution annotations like @EnabledOnJre and @DisabledOnJre.
📄️ JUnit Jupiter best practices
After migrating to JUnit 5, there are several common patterns that should be cleaned up to make tests more modern and maintainable.
📄️ Parameterized tests
Instead of writing multiple similar test methods that differ only in input values and expected results, use @ParameterizedTest to run the same test logic with different parameters. This reduces code duplication and makes it easier to add more test cases.
📄️ Nested tests
JUnit Jupiter supports nested test classes to better organize related tests and share setup code.
📄️ Practice: Migrate to JUnit 5
Ready to practice migrating from JUnit 4 to JUnit 5? We've prepared a test class with common JUnit 4 patterns that you can improve.
📄️ Practice: Parameterized Class
Ready to practice using JUnit 6's @ParameterizedClass to parameterize entire test classes? We've prepared a test class