Quick revision
The short answer
Moving from JUnit 4 to JUnit 5 meant a new architecture: the JUnit Platform that launches tests, Jupiter as the new programming model, and Vintage to keep running JUnit 4 tests. Runners and rules were replaced by the extension model, and annotations and assertions changed names and packages. JUnit 6 is a smaller step: it gives the Platform, Jupiter and Vintage one shared version number, raises the Java baseline, and deprecates the Vintage engine, while most Jupiter tests run unchanged; check the release notes for exact details.
What to remember
In this answer, we saw that JUnit 5 split testing into the Platform, the Jupiter engine and the Vintage engine, replaced runners and rules with the composable extension model, and renamed annotations and reordered assertion messages. JUnit 6 builds on that design with one version number for all parts, a Java 17 baseline, removal of old deprecated APIs and a deprecated Vintage engine. For Jupiter users the upgrade is small, while JUnit 4 tests should now be migrated.
Your turn
Answer it aloud as you would in the interview, or type your answer below. Then show one part at a time and compare.
Moving from JUnit 4 to JUnit 5 meant a new architecture: the JUnit Platform that launches tests, Jupiter as the new programming model, and Vintage to keep running JUnit 4 tests. Runners and rules were replaced by the extension model, and annotations and assertions changed names and packages. JUnit 6 is a smaller step: it gives the Platform, Jupiter and Vintage one shared version number, raises the Java baseline, and deprecates the Vintage engine, while most Jupiter tests run unchanged; check the release notes for exact details.
Why this question is asked
Most Java teams have lived through the JUnit 4 to 5 move, and many now face JUnit 6, which arrived in 2025. Interviewers ask about both to see whether we understand the architecture, not just the new annotation names, and whether we know how much work each upgrade really is. In this answer, we will recap how JUnit 5 is built, walk through what changed in test code from JUnit 4, see what JUnit 6 changes on top of JUnit 5, and finish with what this means for planning.
1A Quick Recap of How JUnit 5 Is Built
JUnit 4 was one jar: the API we wrote tests against and the code that ran them were the same thing, which made it hard for build tools and IDEs to evolve. JUnit 5 split it into three parts. The JUnit Platform is the foundation that discovers and launches tests; Maven Surefire, Gradle and the IDEs talk only to the Platform. On top of it sit test engines. Jupiter is the engine for the new programming model, with its annotations, assertions and extension model. Vintage is an engine that runs JUnit 4 tests on the Platform, so old and new tests can run in the same build.
Notice that this design also allows other engines, such as those for Cucumber, Spock or ArchUnit, to run through the same Platform. That is why the Platform became the common base for Java testing tools.
- Build tools and IDEsMaven Surefire, Gradle, IntelliJ, Eclipse
- JUnit Platformdiscovers and launches tests, reports results
- Test enginesJupiter (new API), Vintage (JUnit 4), third-party engines
- Our testswritten against Jupiter, or old JUnit 4 tests
4 layers, from the top down. Step through them one at a time.
2What Changed in Test Code From JUnit 4
The visible changes are in the annotations and their package, org.junit.jupiter.api instead of org.junit. @Before and @After became @BeforeEach and @AfterEach, @BeforeClass and @AfterClass became @BeforeAll and @AfterAll, @Ignore became @Disabled, and test classes and methods no longer need to be public. Assertions moved to the Assertions class, and the optional message became the last parameter instead of the first.
The deeper change is the extension model. In JUnit 4, behaviour was added with a Runner, such as SpringJUnit4ClassRunner or MockitoJUnitRunner, and a class could only have one runner, so combining Spring and Mockito was awkward. Rules (@Rule, @ClassRule) added behaviour around tests, but with limited hooks. JUnit 5 replaced both with extensions, classes that implement callback interfaces such as BeforeEachCallback or ParameterResolver and are registered with @ExtendWith. A class can have many extensions, so @ExtendWith(SpringExtension.class) and @ExtendWith(MockitoExtension.class) work together. JUnit 5 also added nested tests, parameterized tests in the core project, dynamic tests, display names, tags and parallel execution.
3What JUnit 6 Changes Compared With JUnit 5
JUnit 6.0 came out in 2025. The first change is versioning. In JUnit 5, the Platform had versions like 1.12 while Jupiter and Vintage had 5.12, which confused everyone managing dependencies. JUnit 6 uses one version number, 6.0.0, for all three parts.
The second change is the baseline. JUnit 6 requires Java 17 or newer, where JUnit 5 required Java 8, and it raises the Kotlin baseline as well. The third is cleanup: APIs that had been deprecated during the 5.x line were removed, and the code was annotated with JSpecify nullness annotations. And the Vintage engine is deprecated, which is the clear signal that JUnit 4 tests should be migrated rather than run on Vintage forever. These are the main points; there are other changes, such as changes to CSV parsing in parameterized tests, so we should read the release notes for the exact list before upgrading.
| JUnit 4 | JUnit 5 | JUnit 6 | |
|---|---|---|---|
| Structure | one jar | Platform + Jupiter + Vintage | same parts |
| Versions | 4.13.x | Platform 1.x, Jupiter 5.x | one version, 6.x |
| Java baseline | Java 5+ | Java 8+ | Java 17+ |
| Extending | Runners and Rules | extension model | extension model |
| JUnit 4 tests | native | via Vintage engine | Vintage deprecated |
4What This Means for Planning
For teams on JUnit 5 with Jupiter tests, moving to JUnit 6 is usually a dependency change plus fixing any use of APIs that were deprecated in 5.x; most tests compile and run with little or no change. The BOM makes it easy, because all modules share one version.
For teams still running JUnit 4 tests through Vintage, JUnit 6 is a reminder that the bridge is closing. They can stay on Vintage for now, since deprecation is not removal, but they should plan to convert tests to Jupiter, starting with automated tools for annotations and assertions and doing runners and rules by hand. Frameworks matter too: Spring Boot's test support targets Jupiter, so new test features arrive there first. Check which JUnit version your Spring Boot version manages before overriding it.
5Follow-up questions
Can JUnit 4 and JUnit 5 tests live in the same project?
Yes. With the Vintage engine on the test classpath, the Platform runs JUnit 4 tests alongside Jupiter tests in one build. This is how most teams migrated gradually. In JUnit 6 Vintage still works but is deprecated, so it should be treated as temporary.
Why did JUnit 5 separate the Platform from Jupiter?
So that tools depend on a stable launching API instead of on the test-writing API. IDEs and build tools only need to support the Platform once, and any engine, Jupiter, Vintage or a third-party one, works with them. In JUnit 4, tools reached into internals, which made the framework hard to change.
Do I need to change my extensions for JUnit 6?
Usually not, if they only use the documented extension interfaces. Extensions that relied on APIs deprecated during JUnit 5 need updating, so it is worth compiling them against JUnit 6 and reading the release notes for removed methods.
6Conclusion
In this answer, we saw that JUnit 5 split testing into the Platform, the Jupiter engine and the Vintage engine, replaced runners and rules with the composable extension model, and renamed annotations and reordered assertion messages. JUnit 6 builds on that design with one version number for all parts, a Java 17 baseline, removal of old deprecated APIs and a deprecated Vintage engine. For Jupiter users the upgrade is small, while JUnit 4 tests should now be migrated.
Open with
Going from JUnit 4 to 5 was a real architecture change. JUnit 5 split into the Platform, which IDEs and build tools use to discover and launch tests, the Jupiter engine with the new API, and the Vintage engine that runs old JUnit 4 tests, so we could migrate gradually.
Then, if they want more
In code, the annotations moved to org.junit.jupiter.api and changed names, like @Before to @BeforeEach and @BeforeClass to @BeforeAll, assertion messages moved to the last parameter, and expected exceptions became assertThrows.
The biggest change was replacing runners and rules with the extension model: a class could only have one runner, but it can have many extensions, so SpringExtension and MockitoExtension work together. JUnit 6, released in 2025, is a smaller step.
It gives the Platform, Jupiter and Vintage one version number, raises the baseline to Java 17, removes APIs that were deprecated during 5.x and deprecates the Vintage engine.
So Jupiter tests usually run on JUnit 6 with little or no change, mostly a version bump through the BOM, while teams with JUnit 4 tests should plan to migrate them instead of relying on Vintage. I would check the release notes for the exact list before upgrading.
About this answer
- Last updated
- 12 November 2026
- Versions it names
- JUnit 4, JUnit 5, JUnit 6, Java 17
- Checked
- Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the documentation below. What the checks cover
- Where the question comes from
- Written by Scrivio for practice. It is not taken from an interview.
- Official documentation
- JUnit user guide
Report an issue with this answer
Copy the line below and send it to the author with what you found. It carries the address of this page.
Issue with "What changed for teams moving from JUnit 4 to JUnit 5, and what does JUnit 6 change...": https://scrivio-interview-library.netlify.app/java/junit/c619b24425/