Scrivio Interview library
LeadershipAdvanced6 min read · updated 12 November 2026

Several teams want to stay on JUnit 4 because 'it works'. As the engineering lead for 80 services, how do you decide whether to force migration?

I would decide with a cost and risk assessment rather than a rule: JUnit 4 works today but is in maintenance mode, and the risk is that the tools around it, the Vintage engine and Spring's test integration, move on without it. Against the cost per service (number of tests, custom rules and runners) we weigh the benefits of Jupiter, then allow mixed suites with all new tests in Jupiter, make the migration cheap with OpenRewrite and a shared library of rule replacements, and set a deadline tied to a platform upgrade so the work lands in planned time.

Why this question is asked

'It works' is a strong argument, and a lead who ignores it loses the team's trust. But 'it works' describes today, and a test framework is a dependency we keep for a decade. Interviewers ask this leadership question to see how we balance a team's reasonable resistance against risk to the whole organisation, and whether we can make a migration cheap enough that forcing it becomes unnecessary. In this answer, we will understand the real risk of staying, measure the cost per service, look at the benefits honestly, and build a plan that ends the debate with a deadline the teams can accept.

1Understanding the Real Risk of Staying

JUnit 4 is in maintenance mode: its last release, 4.13.2, is from 2021, and it receives no new features. That alone is not a problem; stable libraries can be fine for years. The risk is in the things around it. JUnit 4 tests run on modern builds through the JUnit Platform's Vintage engine, and Vintage is deprecated in newer JUnit releases. Spring's test support focuses on Jupiter, with SpringExtension receiving the new features and the JUnit 4 runner and rules kept only for compatibility. New libraries ship Jupiter extensions first, sometimes only.

So the question is not whether JUnit 4 works today. It is what happens to these 80 services when a platform upgrade, such as a new Spring Boot generation or JUnit 6, makes the old path harder. A migration done under pressure during that upgrade is far more expensive than one planned ahead.

2Measuring the Cost per Service

Not all 80 services are equal. A quick inventory, which a script over the repositories can produce in an afternoon, tells us for each service how many JUnit 4 test classes it has, how many custom rules and runners it uses, and whether it uses Parameterized, Theories or other JUnit 4-specific features. Plain tests with @Before, @Test and assertions migrate almost entirely automatically. Custom rules and runners need hand work. The inventory usually shows a long tail: most services are cheap, and a few with years of custom runners are expensive.

Inventory of JUnit 4 usage (example)
GroupServicesTypical contentEstimated effort
Plain tests52@Before, @Test, assertionshours, mostly automated
Common rules and runners21Mockito, Spring, TemporaryFolder1-3 days each
Custom rules and runners7home-grown runners, Theories1-3 weeks each
Numbers are an illustration; the real inventory drives the plan.

3Weighing the Benefits Honestly

The benefits of Jupiter are real but should not be oversold. One extension model replaces runners and rules, and extensions combine, where a JUnit 4 class could have only one runner. @ParameterizedTest with sources is far more flexible than the Parameterized runner. Nested tests, display names, built-in parallel execution, @TempDir and better assumptions and timeouts make tests clearer. And having one platform and one style across 80 services makes shared tooling, such as reporting listeners and test analytics, simpler.

For a team whose service changes rarely, those benefits are small. For a team writing new tests every week, they are large. That difference is why the policy should treat new tests and old tests differently.

4The Policy: Mixed Suites Now, All New Tests in Jupiter

The first step costs almost nothing and has no downside: from now on, every new test is written in Jupiter. With junit-vintage-engine next to junit-jupiter, a service runs both kinds in the same build, so nobody has to migrate anything to comply. A simple build check, for example an ArchUnit rule or a search in the pull request, flags new files that import org.junit.Test.

This stops the old code from growing and lets teams learn Jupiter on new work. Teams then migrate old classes when they touch them, which spreads the work across normal development.

5Making the Migration Cheap

Most resistance is really about cost, so the best argument is to remove the cost. OpenRewrite's JUnit 4 to 5 recipe converts imports, annotations, assertion message order, expected exceptions and common runners automatically, and a platform team can run it across many services and open pull requests that teams only review. For the custom rules found in the inventory, a shared library of Jupiter extensions replaces the most common ones once, for everyone, instead of each team rewriting the same database cleanup rule.

Java
// Shared library: one Jupiter replacement for a rule many teams copied
public class CleanDatabaseExtension implements AfterEachCallback {
@Override public void afterEach(ExtensionContext ctx) {
DataSource ds = SpringExtension.getApplicationContext(ctx).getBean(DataSource.class);
JdbcTestUtils.deleteFromTables(new JdbcTemplate(ds), "order_line", "orders");
}
}
// Teams replace @Rule public CleanDatabaseRule db = ... with @ExtendWith(CleanDatabaseExtension.class)

6A Deadline Tied to a Platform Upgrade

A plan without a date drifts forever, but an arbitrary date feels like a mandate from nowhere. So the deadline is tied to something the teams already have to do, such as the move to the next Spring Boot generation or JUnit 6, where staying on JUnit 4 becomes genuinely harder. 'JUnit 4 must be gone from a service before it moves to Boot 4' puts the migration inside planned work, gives a reason everyone can see, and lets each team choose when within that window. The seven expensive services get support from the platform team and an earlier start.

If a team still makes a strong case, for example a service scheduled for retirement within a year, an exception with an end date is fine. The goal is less risk across 80 services, not perfect uniformity.

Step throughDecision for each service
  1. Service retiring within a year?
    YesException with an end dateNoContinue
  2. New tests in Jupiter from todayenforced by a build check
  3. Plain or common-rule tests only?
    YesAutomated migration pull requestNoCustom rules: shared extensions plus planned work
  4. JUnit 4 gone before the platform upgradethe deadline

4 steps in order. Play them, or step through them one at a time.

7Follow-up questions

What if the team says the migration has no customer value?

That is fair for the migration itself, and it is why we make it cheap and tie it to an upgrade they need anyway. The customer value is indirect: the platform upgrade brings security fixes and support, and it is blocked or made expensive by JUnit 4. Framing it as part of that upgrade, rather than as a separate project, usually ends the argument.

Would you ever force a big-bang migration across all services?

Only if a hard external deadline required it, such as a framework end of life with no workaround. Otherwise, gradual migration with automation is cheaper and less risky, because each service moves in a small, reviewable change and teams keep shipping.

8Conclusion

In this answer, we treated the JUnit 4 question as a decision about cost and risk. The risk of staying comes from the ecosystem, a deprecated Vintage engine and Spring test support focused on Jupiter, more than from JUnit 4 itself. An inventory of tests, rules and runners per service shows where the cost lies; mixed suites with all new tests in Jupiter stop the growth at no cost; OpenRewrite and a shared library of rule replacements make the migration cheap; and a deadline tied to a platform upgrade puts the remaining work into planned time.

What to say in the interviewAbout 90 seconds aloud

Open with

I would not decide this on principle. Their point is fair: JUnit 4 works today. The risk is the ecosystem.

Then, if they want more

JUnit 4 is in maintenance mode, its tests run through the Vintage engine, which is deprecated in newer JUnit releases, and Spring's test support and new libraries focus on Jupiter. So the danger is being forced into a rushed migration during some future platform upgrade.

First I would measure: a script over the 80 repositories to count JUnit 4 classes, custom rules and runners per service. Usually most services are plain tests that migrate almost automatically, and a few have custom runners that are expensive. Then a policy in steps.

Immediately, all new tests are written in Jupiter, with a build check; mixed suites run fine with the Vintage engine, so nobody has to migrate anything to comply.

To make the old tests cheap, the platform team runs OpenRewrite's JUnit 4 to 5 recipe and opens pull requests, and we build a shared library of Jupiter extensions for the rules many teams copied.

Finally, the deadline is tied to a platform upgrade the teams need anyway, for example no JUnit 4 left before moving to the next Spring Boot generation, so the work lands in planned time. A service close to retirement can have an exception with an end date.

About this answer

Last updated
12 November 2026
Versions it names
JUnit 4, JUnit 6
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 "Several teams want to stay on JUnit 4 because 'it works'. As the engineering lead for 80...": https://scrivio-interview-library.netlify.app/java/junit/d3f301a054/