Scrivio Interview library
LeadershipPrincipal6 min read · updated 12 November 2026

Engineering spends a large and growing share of its CI budget and developer waiting time on test suites, while escaped defects are not falling. As the senior technical leader, how do you set direction on test strategy and its cost?

I would treat tests as an investment and measure their cost and return: CI spend, developer wait time, flaky-test rate and escaped defects by category. Then I would shift effort toward the tests that catch the defects that actually escape, such as contract tests and tests against real databases, and away from slow, broad tests that rarely fail for real reasons. Shared test infrastructure is funded centrally, pre-production testing is combined with progressive delivery and production monitoring, and organisation-wide targets are reviewed with teams every quarter.

Why this question is asked

When CI costs grow every quarter while the same kinds of bugs reach customers, the test strategy has stopped paying for itself. More tests of the same kind will not fix it, and cutting tests blindly will make it worse. At the senior level, interviewers want to see how we turn a vague worry into data, a direction, and a way to keep track. In this answer, we will set up the measurements, use them to find where testing effort is wasted, decide where to invest instead, add production safety nets, and set up the review cadence that keeps the direction honest.

1Framing Tests as an Investment

Every test has a cost: compute time on CI, developer time spent waiting for it, and maintenance when it breaks for reasons unrelated to a bug. Its return is the defects it catches before customers do. A test that runs 40,000 times a year and has never failed for a real reason is pure cost. A slower test that catches a data corruption bug twice a year may be the best money we spend.

So the question to leadership and to teams is not 'how many tests do we have' or 'what is our coverage', but 'what does our testing cost, and which defects does it stop'. That framing also makes the conversation with finance straightforward, because CI spend becomes something we manage against a return.

2Measuring Cost and Return

I would start a small effort to collect four numbers per service and per test suite. CI cost comes from the CI provider's billing or runner hours. Developer wait time is the median and 90th percentile time from push to a result, multiplied by how often people push. The flaky rate is the share of runs that fail and then pass on retry with no change. Escaped defects come from incident and bug records, each tagged with the kind of defect and the earliest test layer that could have caught it.

The tagging is the important part. When we look at the last 50 escaped defects and see, for example, that 18 were contract mismatches between services, 12 were database behaviour such as a missing index or a constraint, 10 were configuration differences between environments, and only 3 were logic errors, we know where tests are missing. If most of our CI time goes to broad UI and end-to-end suites, we also know where it is being spent.

Example: where defects escape versus where CI time goes
Defect kind (last 50)EscapedTest layer that would catch itShare of CI time
Contract mismatch between services18Contract tests2%
Database behaviour, migrations12Tests on a real database engine8%
Configuration and environment10Progressive delivery, monitoring0%
Business logic3Unit tests15%
UI and broad end-to-end flows7A few journey tests75%

3Shifting Effort to Where Defects Escape

With that picture, the direction is clear. We invest in contract tests between services, because they catch the largest category cheaply and fail in the build of the team that caused the break. We run persistence tests against the real engine with Testcontainers instead of in-memory substitutes, because that is where database behaviour bugs are visible. And we cut back the broad suites that take most of the time but catch few real defects, keeping a handful of critical journey tests rather than trying to cover everything end to end.

I would also make flaky tests a first-class problem. A test that fails randomly costs re-runs, but worse, it teaches people to ignore red builds, which hides real failures. A policy of quarantining a flaky test within a day and fixing or deleting it within a sprint restores trust in the signal.

4Funding Shared Infrastructure Centrally

If every team must optimise its own pipeline, each one reinvents test containers, caching and parallelisation, and most will not get to it. So I would fund a small platform effort to provide shared test infrastructure: a test starter with pinned container images, pre-pulled images and build caches on CI runners, test-impact analysis that runs only affected tests on pull requests, and contract-testing tooling with a broker. Each improvement made once applies to every team, which is why it pays centrally and rarely pays per team.

5Combining Pre-Production Tests With Production Safety Nets

Some failures only appear in production: real traffic patterns, real data, a configuration value that differs, an interaction with a dependency's version. No amount of pre-production testing catches all of them, and trying to is how CI budgets explode. So the strategy also invests after deploy: progressive delivery such as canary releases that send a small percentage of traffic to the new version, automatic rollback on error-rate or latency changes, feature flags, and good monitoring with alerts on user-facing symptoms.

In the example above, the 10 configuration defects are best caught this way. A canary that serves 5 percent of traffic for 15 minutes and rolls back automatically turns a customer-facing incident into a few failed requests.

Step throughWhere each kind of defect gets caught
  1. Unit and slice testslogic, mappings, security rules
  2. Tests on real infrastructureSQL, migrations, messaging
  3. Contract testsAPI agreements between services
  4. Canary releasesmall share of real traffic
  5. Healthy?
    YesRoll forward to everyoneNoAutomatic rollback

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

6Targets and Quarterly Review

Last, I would set organisation-wide targets, such as main build under 10 minutes at the 90th percentile, flaky rate under 1 percent, and escaped defects in the contract and database categories down by half within two quarters. Each quarter I would review the dashboard with team leads, look at which services are off target and why, and adjust investments. The review is not a ranking of teams; it is where we learn which practices worked and spread them.

7Follow-up questions

How do you convince teams to delete tests?

With their own data. Showing that a suite took 6,000 CI hours last quarter and caught no real defect, while a category of bugs it was meant to catch kept escaping, makes the case. We delete or rewrite those tests and redirect the effort, rather than just removing coverage.

Is code coverage a useful target here?

Only as a weak signal. High coverage from broad tests can coexist with escaping defects, as in this situation. I would rather track escaped defects by category and the time and cost of the suite, and use coverage to find untested areas, not as a goal.

What if leadership wants a quick saving?

Test-impact analysis and caching usually cut CI cost noticeably within weeks without reducing what is tested, because pull requests stop running unaffected tests. That buys time and credibility for the slower structural change.

8Conclusion

In this answer, we framed tests as an investment, measured CI cost, wait time, flakiness and escaped defects by category, and used those numbers to move effort toward contract tests and real-database tests and away from broad suites that rarely catch real bugs. We funded shared test infrastructure centrally, added progressive delivery and monitoring for failures only production reveals, and set organisation-wide targets that are reviewed with teams every quarter.

What to say in the interviewAbout 80 seconds aloud

Open with

I would start by treating tests as an investment with a cost and a return, and measure both. Cost is CI spend, developer wait time and the flaky-test rate.

Then, if they want more

Return is the defects tests catch, so I would tag recent escaped defects by kind and by the earliest layer that could have caught them. Typically that shows a mismatch: most CI time goes to slow, broad end-to-end tests, while the escaping bugs are contract mismatches between services, database behaviour and configuration.

So I would shift effort: contract tests between services, persistence tests on the real database engine with Testcontainers, and a few critical journey tests instead of broad end-to-end coverage. Flaky tests get quarantined within a day and fixed or removed within a sprint, because they teach people to ignore red builds.

I would fund shared test infrastructure centrally, things like a test starter with pinned images, CI caching and test-impact analysis, because every team benefits and few would build it alone. I would also accept that some failures only show up in production, so canary releases with automatic rollback and good monitoring are part of the test strategy.

Finally I would set targets for build time, flakiness and escaped defects, and review them with teams each quarter.

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.
Official documentation
Spring Boot reference, Testing
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 "Engineering spends a large and growing share of its CI budget and developer waiting time...": https://scrivio-interview-library.netlify.app/spring-boot/spring-boot-test/6a2ab5b14b/