Scrivio Interview library
LeadershipPrincipal6 min read · updated 12 November 2026

A 15-year-old Java system with little automated testing is critical to the business. How would you plan test investment over several years?

I would invest where change and risk are concentrated, not try to raise coverage everywhere. Every change that touches legacy code must come with tests, so coverage grows where work happens. Early on, I would add a few end-to-end safety nets around the business-critical flows, then push tests down to faster levels as code is refactored. I would track defect escape rate and change lead time to show the return, and make all of this part of normal delivery rather than a separate testing project that can be cancelled.

Why this question is asked

Old systems that run the business are where testing investment matters most and where it most often fails. Large testing programmes get approved, produce a burst of activity, and get cancelled when a deadline arrives, leaving the system no safer. Interviewers ask this to see whether a senior candidate can plan for years, prioritise with data, and keep investment alive through changing priorities. In this answer, we will look at how to decide where to invest, the rule that makes coverage grow by itself, the order of test levels over the years, how to measure the return, and how to make the investment survive.

1Start With Where Change and Risk Meet

A 15-year-old system might have 1.5 million lines of code, but most of them rarely change. Version control tells us which files are touched most often, and incident and defect records tell us where failures came from. Plotting the two together usually shows that a small part of the code, often 5 to 10 percent, accounts for most of the changes and most of the incidents. That is where testing investment returns the most.

So the first quarter of the plan is analysis, not test writing. We list the business-critical flows, such as taking an order, billing and month-end reporting, and map them to the modules they use. We rank modules by change frequency, defect history and business impact. Code that is stable, rarely changed and low risk gets no special investment; trying to backfill tests there is expensive and protects little.

Deciding where to invest first
ModuleChanges per yearIncidents in 2 yearsBusiness impactPriority
Billing rules1409RevenueFirst
Order intake956RevenueFirst
Customer profile602MediumSecond
Reporting exports203Month-endSecond
Archive and purge40LowLeave for now
Illustrative numbers: change frequency and incident history together point at where tests pay off.

2The Rule That Makes Coverage Grow by Itself

The most important policy is simple: any change to legacy code comes with tests for the behaviour it touches. Before changing a method, the engineer writes characterisation tests that record its current behaviour, then writes a test for the new behaviour. Reviewers enforce it, and diff coverage in CI makes it visible.

This rule has a useful property. Because change is concentrated, the tests accumulate exactly where future changes will happen. After two years, the busiest 10 percent of the code is usually well tested, while untouched code stays untested, which is fine because nobody is changing it. The investment is proportional to the work, so it never becomes a separate budget line.

3Safety Nets First, Then Push Tests Down

In the first year, legacy code is often too tangled for unit tests: static calls, huge classes, database access everywhere. So we start at the top, with a small number of end-to-end tests for the critical flows. Perhaps 20 to 40 tests that place an order, bill it and check the resulting records. They are slow and occasionally flaky, but they catch the catastrophic regressions, and they let teams refactor with some confidence.

As teams refactor the busy modules, they create seams, extract classes and introduce interfaces. That makes faster tests possible: integration tests with Testcontainers for the database, and unit tests for extracted business rules. Over years 2 and 3, the bulk of the testing moves down to these faster levels. The end-to-end suite stays small and stable, covering only the flows where a full journey must be checked.

Step throughA multi-year shape of the plan
  1. Year 1, first quarteranalyse change and incident hot spots
  2. Year 1end-to-end safety nets for critical flows
  3. Year 1 onwardevery legacy change ships with tests
  4. Years 2 and 3refactor hot spots; integration and unit tests grow
  5. Year 3 onwardend-to-end suite stays small; most tests are fast
  6. Every quarterreview escape rate and lead time; adjust priorities

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

The test pyramid is built from the top down in a legacy system, then rebalanced.

4Measuring the Return

A multi-year investment needs evidence, or it will not survive the next budget round. Coverage alone is a weak argument, because it can rise without quality improving. I would track two outcome measures from the start. The defect escape rate is the number of defects found in production per release, ideally broken down by module. Change lead time is how long a change takes from commit to production, which falls when teams no longer need long manual regression cycles.

A realistic story after 18 months might be: incidents in the billing module down from nine a year to three, the manual regression phase cut from two weeks to two days, and lead time from five weeks to ten days. Those are numbers executives understand. Coverage of the hot spot modules is reported alongside as supporting evidence, not as the headline.

5Making It Part of Normal Delivery

The failure mode I would most want to avoid is a separate testing project with its own team and budget. It looks committed, but it competes with features, its value is invisible to product owners, and it is the first thing cut when a deadline slips. When it is cut, nothing remains.

Instead, testing becomes part of how every change is done. Estimates include writing tests for legacy code touched. The definition of done includes them. A small platform group, perhaps two engineers, provides shared tools: test data builders, Testcontainers setups for the old database, a fast way to run the end-to-end safety nets. Product teams do the testing in the course of their own work. That way the investment continues automatically through reorganisations and priority changes.

6Follow-up questions

What would you do about the parts of the system nobody changes?

Mostly nothing, beyond making sure the end-to-end safety nets cover the business flows that use them. Tests protect against regressions caused by change, so code that does not change gains little from them. If such code ever becomes a hot spot, the change-with-tests rule picks it up then.

How do you handle end-to-end tests that become flaky?

Track flakiness per test, quarantine a flaky test quickly so it does not block delivery, and fix or replace it within a set time. Most flakiness in legacy end-to-end tests comes from shared test data and timing, so giving each test its own data and waiting on conditions instead of fixed sleeps fixes much of it.

How do you convince teams who say they have no time to write tests?

Show them the time already lost to manual regression testing and production fixes in their own module, and make test writing part of the estimate rather than extra work. The first time a characterisation test catches a regression before release, the argument usually wins itself.

7Conclusion

In this answer, we planned test investment for a critical 15-year-old system. We focused on modules where change and risk meet, required tests with every change to legacy code so coverage grows where work happens, added end-to-end safety nets early and pushed tests down as code was refactored, measured return with defect escape rate and lead time, and built the work into normal delivery so it cannot be cancelled as a separate project.

What to say in the interviewAbout 90 seconds aloud

Open with

I would start with data rather than a coverage target. Version control and incident history usually show that a small part of an old system, maybe 5 to 10 percent, gets most of the changes and causes most of the incidents, so that is where tests pay off.

Then, if they want more

Code that nobody changes gets no special investment. The core policy is that every change to legacy code comes with tests: characterisation tests for the current behaviour first, then a test for the new behaviour. Because changes concentrate in the same places, coverage grows exactly where future work will happen.

In the first year the code is usually too tangled for unit tests, so I would add a small set of end-to-end safety nets for the critical flows, like ordering and billing. As teams refactor the hot spots and create seams, tests move down to integration tests with Testcontainers and unit tests, and the end-to-end suite stays small.

To keep funding, I would show outcomes: defect escape rate per module and change lead time, for example incidents in billing falling from nine a year to three and the manual regression phase shrinking from two weeks to two days.

Most importantly, this would be part of normal delivery, in estimates and the definition of done, not a separate project that gets cancelled.

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 "A 15-year-old Java system with little automated testing is critical to the business. How...": https://scrivio-interview-library.netlify.app/java/test-strategy/1e03fddb3c/