Scrivio Interview library
ScenarioIntermediate6 min read · updated 12 November 2026

Management wants a mandatory 90 percent coverage threshold for all services. How do you respond?

I would agree with the goal, more effective tests, but propose a different rule. A fixed 90 percent threshold for every service pushes engineers to test getters and write tests without assertions just to reach the number. Instead, I would require coverage on new and changed code with a moderate threshold such as 80 percent, exclude generated code and configuration classes from the metric, review test quality in code review, and use mutation testing on the critical modules where defects are expensive.

Why this question is asked

Coverage mandates usually come from a good place: a manager has seen defects reach production and wants a measurable way to push quality up. The way we respond matters as much as the technical answer, because we want to keep their trust while steering towards something that works. Interviewers ask this to see whether we can explain a metric's side effects in business terms and offer a better alternative instead of simply saying no. In this answer, we will look at what management actually wants, what a 90 percent mandate would do in practice, the alternative I would propose with concrete numbers, and how I would present it.

1Start With What Management Wants

Before arguing about a number, it helps to ask what problem the threshold is meant to solve. Usually it is one of three things: too many defects found by customers, fear that changes break existing behaviour, or a need to show auditors or executives that testing happens. Each of these is a fair concern, and none of them is really about the percentage itself.

So my first response is a question: which outcome are we trying to improve, and how will we know it improved? If the answer is fewer escaped defects, we now have a measure that coverage can support, and something to judge any rule against.

2What a Fixed 90 Percent Rule Does in Practice

Coverage measures which lines and branches tests executed. It does not measure whether a test checked anything. When a team with 65 percent coverage is told to reach 90 percent by the end of the quarter, the fastest way there is not to write careful tests for complex logic; it is to cover the easy lines. Getters, setters, constructors, equals() and toString(), mapping classes and configuration all add coverage quickly.

Java
// A test written for the threshold, not for behaviour
@Test void coverOrderDto() {
OrderDto dto = new OrderDto();
dto.setId(7L);
dto.setStatus("NEW");
dto.getId();
dto.getStatus();
dto.toString();
}
// coverage +2.1% for the module, defects found: 0

The other common pattern is the assertion-free test: call the service with some input and assert nothing, or assert only that the result is not null. These tests cost time to write and time to run, they break when code is refactored, and they give the impression of safety without providing any.

There is also a cost in the last few percent. Going from 80 to 90 percent usually means testing error handling for situations that are hard to provoke, which often requires heavy mocking. Those tests are the most brittle in the suite. So a fixed high threshold tends to increase test count and maintenance cost while leaving the real risk, complex business logic with weak assertions, untouched.

3A Better Rule: Coverage on New and Changed Code

The rule I would propose has four parts, and each one fixes a specific weakness of the global threshold.

First, measure coverage on new and changed code, for example 80 percent of the lines changed in each pull request. SonarQube's quality gate supports this through its new code period, and diff-coverage tools do the same in CI. This rule is fair to legacy services, which start at 40 percent and cannot reach 90 overnight, and it makes sure every change comes with tests, so coverage grows where work actually happens.

Second, exclude code that should not count: generated sources such as MapStruct or OpenAPI clients, Lombok-generated methods, Spring configuration classes, and DTOs without logic. Including them inflates or deflates the number for no reason. JaCoCo supports excludes in its plugin configuration, and lombok.addLombokGeneratedAnnotation = true lets JaCoCo skip Lombok-generated code.

Third, make test quality part of code review. A reviewer checks that tests assert specific outcomes, not just that something ran. Fourth, for critical modules such as payments, pricing and permissions, add mutation testing with PIT, which changes the code on purpose and checks whether a test fails. That measures what management actually cares about: would our tests catch a bug?

Two ways to use coverage
AspectFixed 90% for all servicesProposed rule
ScopeWhole codebaseNew and changed code
Threshold90% everywhereAbout 80% on the diff
Generated and config codeCountedExcluded
Legacy servicesBlocked or gamedImprove with each change
Test qualityNot checkedReviewed; mutation testing on critical code
Success measureThe percentageEscaped defects and incidents
The proposed rule keeps a measurable bar but points it at the risk.

4How I Would Present It

I would not present this as a refusal. I would say that we support a measurable quality bar and propose to make it stricter where it matters. Then I would show data from our own services: two or three examples of tests that add coverage without checking anything, and one or two recent incidents in code that was covered but whose tests would not have caught the bug.

Next, I would propose a three-month trial on a few services: diff coverage at 80 percent, exclusions in place, mutation testing on one critical module. We report escaped defects and change failure rate before and after, alongside coverage on new code. If those outcomes improve, management has the evidence it wanted, and it is a much stronger story than a percentage.

If management still wants an overall number, I would accept a moderate floor, such as 70 percent branch coverage on critical services, as a safety net to catch modules with no tests at all, while keeping the diff rule as the main lever.

5Follow-up questions

Is there any situation where a high fixed threshold makes sense?

For a small, critical library with stable code and pure logic, such as a money arithmetic module, a high threshold combined with mutation testing can be reasonable, because the code is easy to test thoroughly. The problem is applying the same number to every service regardless of what the code does.

How do you stop people from gaming diff coverage too?

No metric is game-proof, which is why review is part of the rule. Reviewers look at what the tests assert, and mutation testing on critical modules exposes tests that run code without checking it. Keeping the threshold moderate also reduces the pressure to game it.

What do you exclude from coverage, exactly?

Generated sources, Lombok-generated methods, the Spring Boot main class, configuration classes that only declare beans, and plain DTOs or records without logic. Exclusions should be listed in the build file and reviewed like code, so nobody quietly excludes a hard class to make the number look better.

6Conclusion

In this answer, we saw how to respond to a 90 percent coverage mandate: start from the outcome management wants, explain that a fixed high threshold encourages getter tests and assertion-free tests, and propose a rule that does more. That rule measures coverage on new and changed code with a moderate threshold, excludes generated code and configuration, reviews test quality, and adds mutation testing on critical modules, with escaped defects as the measure of success.

What to say in the interviewAbout 80 seconds aloud

Open with

I would start by agreeing with the intent, because management wants fewer defects reaching customers, and that is the right goal. Then I would explain what a fixed 90 percent rule tends to do.

Then, if they want more

Coverage only measures that code ran. When a team at 65 percent is told to reach 90, the quickest path is testing getters, constructors and mappers, and writing tests that call code without asserting anything. The count goes up, maintenance cost goes up, and the risky logic is no better tested.

Legacy services are either blocked or start gaming the number. So I would propose a stricter rule aimed at the risk. Every pull request needs around 80 percent coverage on the lines it changes, which SonarQube's new code gate supports, so coverage grows where we actually work.

Generated code, Lombok methods and configuration classes are excluded so the number means something. Reviewers check that tests assert real outcomes. And for critical modules like payments or pricing we add mutation testing with PIT, which checks whether tests would catch a bug.

I would offer a three-month trial on a few services and report escaped defects and change failure rate before and after, so management gets evidence about quality rather than just a percentage.

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 "Management wants a mandatory 90 percent coverage threshold for all services. How do you...": https://scrivio-interview-library.netlify.app/java/test-strategy/84c7033daa/