Scrivio Interview library
ScenarioIntermediate6 min read · updated 12 November 2026

You join a team with 6,000 TestNG tests and the platform team asks everyone to move to JUnit 5 or 6. How do you decide and plan?

We weigh the cost of moving, rewriting dependencies, data providers, factories, groups, listeners and suite files and fixing the reversed assertion order, against the value of shared tooling, Spring Boot test support, extensions and fewer framework experts. A low-risk plan is to run both frameworks on the JUnit Platform through the TestNG engine, write new tests in Jupiter, and migrate old tests when they are touched or in batches with automated tools such as OpenRewrite recipes, reviewing the manual cases. We agree success criteria, equal test counts, no lost tests and run time, and a deadline for removing TestNG.

Why this question is asked

A platform-wide request to standardise on one test framework sounds simple until we count what it touches: 6,000 tests, written over years, with their own conventions and edge cases. A rushed rewrite can quietly drop tests or weaken assertions, while refusing to move leaves the team on a path that the rest of the company no longer supports. Interviewers ask this scenario to see whether we can turn a policy request into an evidence-based decision and a plan with measurable safety. In this answer, we will take an inventory, weigh cost and value, look at the option of running both frameworks side by side, plan the migration itself with automation, and define how we know nothing was lost.

1Start With an Inventory

Before deciding anything, we count what the 6,000 tests actually use, because plain TestNG tests are cheap to move and some features are expensive. A few searches over the codebase give the numbers.

Text
grep -rl "org.testng" src/test | wc -l # 410 test classes
grep -r "dependsOnMethods\|dependsOnGroups" src/test | wc -l # 95 dependencies
grep -r "@DataProvider" src/test | wc -l # 180 data providers
grep -r "@Factory" src/test | wc -l # 6 factories
grep -rl "implements I.*Listener" src/test | wc -l # 9 custom listeners
find . -name "testng*.xml" | wc -l # 12 suite files

These numbers shape the plan. Plain @Test methods with assertions, often 80 to 90 percent of a suite, convert almost mechanically. Data providers map well to @ParameterizedTest with @MethodSource. Dependencies, factories, custom listeners and suite files need design work, because Jupiter has no dependencies, uses @TestFactory or parameterized classes instead of factories, and uses extensions instead of TestNG listeners.

2Weighing Cost Against Value

The cost side includes the rewriting effort, the review effort, and the risk of mistakes. The most common mistake is the assertion order: TestNG's assertEquals(actual, expected) versus Jupiter's assertEquals(expected, actual), which leaves tests passing but with misleading failure messages if it is not converted. Tests that rely on TestNG's one instance per class, sharing fields between methods, change behaviour under Jupiter's per-method instances.

The value side is real too. Spring Boot's test support, Testcontainers and Mockito all centre on Jupiter extensions, so new tests become easier to write. Shared tooling from the platform team, such as reporting listeners, test-data libraries and CI templates, only has to support one framework. New team members already know Jupiter, so fewer people need to be TestNG experts. Over several years, these savings usually outweigh a one-time migration, which is why the platform team asks for it.

Migration cost by feature (from the inventory)
TestNG featureCountJupiter targetEffort
Plain @Test with assertionsabout 5,200 tests@Test, assertion order swappedAutomated
@DataProvider180@ParameterizedTest + @MethodSourceMostly automated
groupsused widely@TagAutomated
dependsOnMethods / Groups95Independent tests or one journey testManual design
@Factory6@TestFactory or parameterized classesManual
Custom listeners9Extensions or Platform listenersManual
Suite XML files12Tags and build configurationManual

3Running Both Frameworks Side by Side

We do not have to switch everything at once. The JUnit Platform can run TestNG tests through the TestNG engine, org.junit.support:testng-engine, next to the Jupiter engine. With both on the classpath and the build configured for the Platform, one test run executes old TestNG tests and new Jupiter tests, and the reports look the same to CI.

This turns a risky big-bang rewrite into a gradual one. From the first day, every new test is written in Jupiter. Old tests migrate when someone touches them for another reason, or in planned batches, one package at a time. If the TestNG engine does not support a feature a few classes rely on, such as a particular suite-file setting, those classes can keep running under the plain TestNG provider in a separate build execution until they are rewritten.

4Automating the Mechanical Part

For the bulk of plain tests, we use automated rewriting. OpenRewrite, a tool that applies recipes, structured code transformations, across a codebase, has testing-framework recipes, and community recipes built on it cover TestNG annotations and assertions; check which recipes are current for your versions. A typical recipe changes imports and annotations and swaps assertion arguments into the Jupiter order.

Java
// Before (TestNG)
import static org.testng.Assert.assertEquals;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
public class CartTest {
@BeforeMethod public void setUp() { cart = new Cart(); }
@Test(groups = "unit")
public void sumsItems() { assertEquals(cart.add(40).add(60).total(), 100); }
}
// After (JUnit Jupiter)
import static org.junit.jupiter.api.Assertions.assertEquals;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;
class CartTest {
@BeforeEach void setUp() { cart = new Cart(); }
@Tag("unit") @Test
void sumsItems() { assertEquals(100, cart.add(40).add(60).total()); } // order swapped
}

Notice the swapped arguments in the last line; that is exactly the change humans forget. The tool handles thousands of these consistently. Developers review each batch, and they handle the manual cases, the 95 dependencies, the factories and the listeners, as small design tasks, often improving the tests along the way, for example turning a dependency chain into independent tests.

5Defining Success and a Deadline

A migration without clear criteria never finishes and can silently lose coverage. We agree three measurable criteria with the platform team before starting. First, test counts: for each migrated package, the number of executed tests before and after must match, accounting for data provider rows becoming parameterized invocations. Second, no lost tests: the list of test names before and after is compared automatically, and every difference is explained. Third, run time: the suite must not become slower, and ideally gets faster as Jupiter's per-method instances allow safer parallelism.

We also agree a deadline for removing TestNG, for example four quarters, with milestones per quarter, say 30, 60, 90 and 100 percent of classes. When the last TestNG class is gone, we remove the TestNG dependency and the engine, so the codebase does not keep two frameworks forever.

Step throughDeciding and planning the move
  1. Inventory TestNG features in usedependencies, providers, factories, listeners
  2. Do cost and value favour moving?
    YesPlan a gradual migrationNoAgree an exception with the platform team
  3. Run both on the JUnit Platformtestng-engine next to Jupiter
  4. New tests in Jupiter from day oneold tests move when touched
  5. Batch-migrate with recipes, review manual casespackage by package
  6. Compare counts and names per batchno lost tests
  7. Remove TestNG at the deadlinedependency and engine

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

6Follow-up questions

What if the team relies heavily on dependsOnMethods for end-to-end flows?

Then those flows need a design decision, not a mechanical rewrite. Usually most chains become independent tests that build their state through API helpers, and a few genuine journeys become single Jupiter tests with several steps, or ordered tests with @TestMethodOrder where a later failure is acceptable. This is often the most valuable part of the migration.

How do you avoid breaking parallel-safety during migration?

TestNG runs all methods on one instance, while Jupiter creates one per method, so tests that shared fields may break or, more subtly, stop testing what they did. We search for fields written in one test and read in another and fix those first, and we run the migrated package several times, also in random order, before merging.

Is it acceptable to keep TestNG for some tests indefinitely?

Only as an explicit, time-limited exception with an owner, for example a specialised suite that depends on TestNG features with no good equivalent. Otherwise two frameworks stay forever, and the platform team keeps paying to support both.

7Conclusion

In this answer, we started the decision with an inventory of TestNG features in use, weighed the cost of rewriting dependencies, data providers, factories, listeners and suite files and swapping assertion order against the value of a shared ecosystem, and chose a gradual migration: both frameworks on the JUnit Platform through the TestNG engine, new tests in Jupiter, old tests moved in reviewed batches with OpenRewrite-style recipes, success measured by matching test counts and names, and a deadline for removing TestNG.

What to say in the interviewAbout 90 seconds aloud

Open with

I would not decide on opinion; I would start with an inventory. I would count the test classes and how many use the expensive TestNG features: dependsOnMethods, data providers, factories, custom listeners and suite files.

Then, if they want more

Plain tests with assertions convert almost mechanically; dependencies, factories and listeners need design work. Then I would weigh it. The cost is the rewriting and review effort plus the risk of mistakes, the classic one being assertion order, since TestNG's assertEquals is actual then expected and Jupiter's is expected then actual.

The value is aligning with the ecosystem: Spring Boot's test support, Testcontainers and Mockito extensions, the platform team's shared tooling, and fewer TestNG experts needed. If the decision is to move, I would avoid a big bang.

I would put the TestNG engine from the JUnit team next to Jupiter on the JUnit Platform, so both run in one build, write all new tests in Jupiter, and migrate old tests when touched or package by package, using OpenRewrite-style recipes for annotations and assertion order, with developers reviewing batches and handling the manual cases.

I would agree success criteria up front: executed test counts and test names match before and after each batch, no lost tests, run time no worse, and a deadline, say four quarters, after which we remove the TestNG dependency entirely.

About this answer

Last updated
12 November 2026
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.
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 join a team with 6,000 TestNG tests and the platform team asks everyone to move to...": https://scrivio-interview-library.netlify.app/java/testng/7470d649b8/