Quick revision
The short answer
First we check the baseline and the stack: JUnit 6 needs Java 17 or later and uses one version number for Platform, Jupiter and Vintage, and every engine, extension, plugin and IDE we use must support it. In a Spring Boot codebase the cleanest route is to move with the Boot generation that ships JUnit 6 rather than overriding the version. Before switching, we compile against the latest 5.x with deprecation warnings on to remove APIs that 6 deletes, then run the whole suite on a branch and compare test counts, because small behaviour changes such as nullability annotations and CSV parsing can affect a few tests.
What to remember
In this answer, we planned a move from JUnit 5 to JUnit 6 by checking constraints before changing versions: the Java 17 baseline across modules and CI, the single version number for all JUnit parts, removal of deprecated APIs found by compiling on the latest 5.x with deprecation warnings, and JUnit 6 support in every engine, extension and build tool. In a Spring Boot codebase we follow the Boot generation that ships JUnit 6 instead of overriding mid-generation, and we run the whole suite on a branch, comparing test counts per module so that quiet losses show up alongside visible failures.
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.
First we check the baseline and the stack: JUnit 6 needs Java 17 or later and uses one version number for Platform, Jupiter and Vintage, and every engine, extension, plugin and IDE we use must support it. In a Spring Boot codebase the cleanest route is to move with the Boot generation that ships JUnit 6 rather than overriding the version. Before switching, we compile against the latest 5.x with deprecation warnings on to remove APIs that 6 deletes, then run the whole suite on a branch and compare test counts, because small behaviour changes such as nullability annotations and CSV parsing can affect a few tests.
Why this question is asked
A major JUnit version touches every module of a large codebase at once, and the failures it causes are often quiet: an engine that no longer loads, a plugin that runs zero tests, a parameterized test that parses its input slightly differently. Interviewers ask this scenario to see whether we plan an upgrade by checking constraints before changing versions, and whether we know what actually changed in JUnit 6. In this answer, we will look at what JUnit 6 changes, check the Java baseline, remove deprecated APIs while still on 5.x, check the ecosystem, choose how to align with Spring Boot, and run the switch in a way that proves nothing was lost.
1What Changes in JUnit 6
JUnit 6 is an evolution of JUnit 5, not a rewrite: tests are still written with org.junit.jupiter.api, and the engine, extension model and annotations stay the same. The changes are around the edges, but they matter for a large codebase. The minimum Java version rises to 17. The three parts now share one version number, so instead of Platform 1.13 next to Jupiter 5.13, everything is 6.0.x. APIs that were deprecated during the 5.x line are removed. The codebase is annotated with JSpecify nullability annotations, which Kotlin and null-checking tools read. Some behaviours changed in detail, for example CSV parsing for @CsvSource and @CsvFileSource moved to a different parser, and the Vintage engine is deprecated.
So the risk is not that our tests stop compiling en masse. It is that some edge breaks somewhere, and in a big suite we must find it.
| Area | What changes | How we check |
|---|---|---|
| Java baseline | Java 17 minimum | build JDK, toolchains, CI images |
| Version numbers | one 6.x version for all modules | BOM, no hand-pinned platform jars |
| Deprecated APIs | removed in 6 | compile on latest 5.x with -Xlint:deprecation |
| Engines and extensions | must support the new platform | release notes of each |
| Behaviour details | nullability, CSV parsing, Vintage | full suite on a branch, compare counts |
2Check the Java Baseline First
The first question is whether every module builds and runs tests on Java 17 or newer. In a large codebase there is often an old library module still compiled for Java 8 or 11 for a legacy consumer, or a CI image with an older JDK. Tests compiled with --release 11 will not load JUnit 6 classes compiled for 17. Maven toolchains, Gradle toolchains and the CI runner images all need checking. If some module must stay below 17, it stays on JUnit 5.x, and the BOM must allow that per module rather than forcing one version everywhere.
3Remove Deprecated APIs While Still on 5.x
The safest order is to fix everything that 6 will remove while we are still on the last 5.x release, where those APIs still exist but are marked deprecated. Compiling the tests with deprecation warnings enabled lists them.
Each warning in JUnit code is a likely compile error after the upgrade. Fixing them on 5.x keeps each change small and the build green throughout. OpenRewrite also has recipes for JUnit 5 to 6 changes, which can do much of this automatically (check the recipe catalogue). Notice also that the old @RunWith(JUnitPlatform.class) runner and its artifact are gone in 6, so any remaining use must move to @Suite first.
4Check the Ecosystem Around JUnit
Our tests rarely use JUnit alone. Other engines run on the same platform: Spock, Cucumber, Kotest, jqwik, ArchUnit's JUnit engine. Extensions plug into Jupiter: Mockito's MockitoExtension, Testcontainers' @Testcontainers, Spring's SpringExtension, WireMock, JUnit Pioneer. And tools launch the platform: Surefire, Failsafe, Gradle and the IDEs. Each of them must have a release that supports JUnit 6. An engine built against an older platform API may fail to load, and a launcher that is too old may not discover tests.
So we make a list from the dependency tree of every module, look up the minimum version of each that supports JUnit 6, and upgrade those first, still on JUnit 5, where possible. That turns one big jump into several small ones.
- All modules build on Java 17+?YesContinueNoUpgrade JDK first or keep those modules on 5.x
- Latest 5.x with deprecation warnings fixed
- Engines, extensions, plugins on JUnit 6-ready versions
- Switch the BOM to 6.x on a branchvia the Spring Boot generation
- Same test counts and results as main?YesMergeNoInvestigate the differences
5 steps in order. Play them, or step through them one at a time.
5Align With Spring Boot Instead of Overriding
In a Spring Boot codebase, Boot's dependency management chooses the JUnit version, and Spring's test support is built and tested against it. Spring Boot 4.0, on Spring Framework 7, is the generation that moves to JUnit 6, while Boot 3.5 stays on JUnit 5.x (check the exact versions in the Boot release notes). Overriding the JUnit version in the middle of a Boot generation is possible through Boot's version property, but it means running a combination nobody tested.
So the clean plan ties the JUnit upgrade to the Boot 4 upgrade. That is a bigger change, with Jakarta EE 11, Spring Framework 7 and other moves, but it means JUnit 6 arrives with a Spring test integration designed for it. If we need JUnit 6 earlier, we try the override on a branch and run the whole suite before deciding.
6Run the Switch on a Branch and Compare
The last step proves we lost nothing. On a branch, we switch the version and run the entire suite, every module, every tag, and compare with the main branch: total tests executed per module, failures, skipped counts. A module whose count drops has an engine or plugin problem, even if it is green. A handful of failures usually point at the behaviour changes, for example a @CsvSource value with unusual quoting that now parses differently, or a custom extension that used a removed internal API.
Notice that the most dangerous result is the quiet one, legacy-export with zero tests, not the two visible failures.
7Follow-up questions
Can JUnit 5 and JUnit 6 modules live in one multi-module build?
Yes, as long as each module's test classpath is consistent, one generation per module. The BOM is then imported per module or per group of modules instead of once at the top. It is a reasonable transition state when some modules cannot move to Java 17 yet.
Do our test classes need rewriting for JUnit 6?
Almost never. The programming model is the same, so most test classes compile unchanged. The work is in deprecated API uses, custom extensions that relied on removed APIs, third-party versions, and the few tests affected by behaviour details.
8Conclusion
In this answer, we planned a move from JUnit 5 to JUnit 6 by checking constraints before changing versions: the Java 17 baseline across modules and CI, the single version number for all JUnit parts, removal of deprecated APIs found by compiling on the latest 5.x with deprecation warnings, and JUnit 6 support in every engine, extension and build tool. In a Spring Boot codebase we follow the Boot generation that ships JUnit 6 instead of overriding mid-generation, and we run the whole suite on a branch, comparing test counts per module so that quiet losses show up alongside visible failures.
Open with
The first thing I check is the baseline: JUnit 6 needs Java 17, so every module, toolchain and CI image must build and run tests on 17 or newer.
Then, if they want more
JUnit 6 also uses one version number for Platform, Jupiter and Vintage, so I make sure nothing pins individual platform jars and everything comes from the BOM. Next, while still on the latest 5.x, I compile the tests with deprecation warnings on, because APIs deprecated in 5 are removed in 6, and I fix those first, maybe with OpenRewrite.
Third, the ecosystem: Spock, Cucumber or other engines, extensions like Mockito, Testcontainers and Spring's, and Surefire, Gradle and the IDEs all need versions that support JUnit 6, so I upgrade those ahead of time.
For Spring Boot, I would not override the JUnit version mid-generation; Boot manages it and Spring's test support is tested against it, so I tie JUnit 6 to the Boot 4 upgrade.
Finally, I switch on a branch and run the entire suite, comparing tests run per module with main, not just pass or fail, because the scary outcome is a module that quietly runs zero tests. A few tests may fail from behaviour changes like the new nullability annotations or CSV parsing details, and those are usually quick to fix.
About this answer
- Last updated
- 12 November 2026
- Versions it names
- JUnit 6, JUnit 5, Java 17, Spring Framework 7
- 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 "You plan to move a large Spring Boot codebase from JUnit 5 to JUnit 6. What do you check...": https://scrivio-interview-library.netlify.app/java/junit/4f1871876d/