Quick revision
The short answer
I would treat disabled tests as tracked debt: every @Disabled needs a reason and a ticket, every disabled or skipped test is counted from the test reports and shown per team on a dashboard, and anything disabled longer than an agreed period, say 90 days, is either fixed or deleted with the owner's approval. Environment-specific conditions stay allowed when they name where the test does run, and the numbers go to engineering managers and quality reviews, not only to developers.
What to remember
In this answer, we saw why disabled tests become more expensive the longer they sit, and how to separate environment-specific conditions from tests that are hiding bugs. The policy is a reason and ticket on every @Disabled, an expiry after which a test is fixed or deleted with the owner's approval, and counting from the test reports we already produce. Tooling enforces the rules at build time and opens tickets, the rollout starts with measuring, and the numbers are shown to managers in quality reviews so that fixing them becomes planned work.
Your turn
Answer it aloud as you would in the interview, or type your answer below. Then show one part at a time and compare.
I would treat disabled tests as tracked debt: every @Disabled needs a reason and a ticket, every disabled or skipped test is counted from the test reports and shown per team on a dashboard, and anything disabled longer than an agreed period, say 90 days, is either fixed or deleted with the owner's approval. Environment-specific conditions stay allowed when they name where the test does run, and the numbers go to engineering managers and quality reviews, not only to developers.
Why this question is asked
Thousands of disabled tests across an organisation is a common situation, and it rarely comes from carelessness. Each test was disabled for a sensible short-term reason, a flaky dependency, a feature behind a flag, a pending fix, and then nobody came back. Interviewers ask this at senior level because the fix is not technical cleverness; it is a policy that people follow, tooling that makes the policy cheap, and visibility that makes it someone's job. In this answer, we will look at why disabled tests are expensive, sort them into kinds, then go through the policy, the tooling that enforces it, how to roll it out without a revolt, and how to make the numbers visible at the right level.
1Why Disabled Tests Are Expensive
A disabled test costs nothing to run, which is exactly why it is dangerous. It still sits in the codebase, it still appears in coverage discussions as 'we have a test for that', and it still has to be compiled and updated during refactoring. Meanwhile the behaviour it was meant to protect has no protection at all.
The longer a test stays disabled, the harder it is to enable. After a few months the code it tests has moved on, the fixture data is stale, and the original author may have left. After two years, enabling it is often more work than writing a new test. So the cost grows with time, and that is the key insight behind an expiry rule.
2Sorting Disabled Tests Into Kinds
Before setting rules, we need to separate tests that are legitimately conditional from tests that are hiding something. A test annotated @EnabledOnOs(OS.WINDOWS) for Windows path handling is fine, as long as some CI job runs on Windows. A test with @Disabled("flaky, fix later") from 2022 is hiding a bug or a broken test. Assumptions sit in between: assumeTrue(dockerAvailable()) is fine on laptops but dangerous on CI.
So the policy treats these kinds differently. Environment conditions are allowed when they state where the test runs. Everything else is debt with an owner and a date.
| Kind | Example | Policy |
|---|---|---|
| Environment condition | @EnabledOnOs(WINDOWS), @EnabledIfSystemProperty | Allowed if a CI job runs it |
| Assumption on infrastructure | assumeTrue(dockerAvailable()) | Allowed locally, must fail in CI |
| Temporarily disabled | @Disabled("JIRA-4411 flaky clock") | Needs ticket, expires after 90 days |
| Disabled without reason | @Disabled | Not allowed in new code |
Commented out or @Ignore leftovers | // @Test | Delete or restore |
3The Policy: Reason, Ticket, Expiry
The first rule is that every @Disabled carries a reason string that contains a ticket key. JUnit already supports this, because @Disabled takes a value, and the reason appears in the test report next to the skipped test. A plain @Disabled with no reason is rejected by the build for new code.
The second rule is an expiry. A test disabled for longer than an agreed period, 90 days is a common choice, must be either fixed and re-enabled or deleted. Deleting a test is a legitimate outcome, but it needs the owning team's approval, because deleting means we accept that the behaviour is unprotected. The decision becomes explicit instead of happening by neglect.
For teams that want the expiry in the code itself, the JUnit Pioneer library offers an annotation that disables a test until a date and then lets it fail again (check its current name and version). Otherwise the ticket's age is enough.
4Tooling That Makes the Policy Cheap
Policies that rely on people remembering fail. So we enforce the first rule at build time with a static check: an ArchUnit rule, a Checkstyle or Error Prone check, or a small custom scanner in the shared build plugin that fails when @Disabled has no value or the value has no ticket pattern such as [A-Z]+-\d+.
For counting, we do not need to scan source code at all. The JUnit XML that Surefire, Failsafe and Gradle already write contains a skipped element for each skipped test, with the reason when there is one. A small job collects these files from every build on the main branch and stores test id, repository, owning team, reason and the first date it was seen as skipped. JUnit's Open Test Reporting format and a shared TestExecutionListener, which receives executionSkipped events with the reason, are richer sources if teams use them.
From that store we get a dashboard per team: how many tests are disabled, how many are aborted by assumptions, how old the oldest ones are, and which are past the expiry. A weekly job opens or bumps tickets for tests that crossed the limit.
- Builds write JUnit XMLskipped tests with reasons
- Collector stores skipped testsid, team, reason, first seen
- Dashboard per teamcount, age, past expiry
- Older than 90 days?YesTicket to the owner: fix or deleteNoKeep watching
- Reviewed in the monthly quality review
5 steps in order. Play them, or step through them one at a time.
5Rolling It Out Without a Revolt
If we switch on the expiry rule tomorrow, thousands of tests cross it on day one and the policy dies of its own weight. So we start by measuring: run the collector for a month and publish the numbers without any rule. That alone usually removes a few hundred tests, because people see them.
Then we grandfather the existing backlog with a deadline per team, enforce reason-and-ticket on new @Disabled annotations immediately, and enforce the expiry on anything disabled after the start date. Each team gets a target, for example halving its backlog per quarter, and the teams decide which tests to fix and which to delete. A cleanup week where teams work through their oldest disabled tests works well alongside it.
6Making It Visible to Managers
Disabled tests are a quality risk that the business carries, so the numbers belong where priorities are set. We include them in the quality or operations review that engineering managers attend, next to incident counts and flaky test rates. A manager who sees that the payments team has 340 disabled tests, the oldest from 2021, can make room in the plan for it. A developer who sees the same number alone usually cannot.
Visibility should not become blame. The message is that the number is a shared risk with a trend, and the goal is to make the trend go down, not to punish the team with the biggest number.
7Follow-up questions
Should we simply delete every test that has been disabled for over a year?
Not blindly. Some of them protect important behaviour and only need a small fix, and deleting them loses that knowledge. The rule should force a decision by the owning team, with deletion as an acceptable outcome. In practice many old tests are deleted, but each deletion is a conscious decision that the behaviour is covered elsewhere or no longer matters.
How do we stop teams from gaming the policy by deleting tests to make the number drop?
We watch two numbers together: disabled tests and executed tests per module, or coverage of the critical areas. If disabled tests fall and executed tests fall by the same amount, the review discusses it. Deletions also need the owner's approval in the ticket, which leaves a trail.
What about tests skipped by assumptions rather than @Disabled?
They are counted from the same reports, as aborted or skipped tests, and shown separately. The policy for them is that each assumption must name an environment where the test does run, and CI must be one of those environments for infrastructure such as Docker.
8Conclusion
In this answer, we saw why disabled tests become more expensive the longer they sit, and how to separate environment-specific conditions from tests that are hiding bugs. The policy is a reason and ticket on every @Disabled, an expiry after which a test is fixed or deleted with the owner's approval, and counting from the test reports we already produce. Tooling enforces the rules at build time and opens tickets, the rollout starts with measuring, and the numbers are shown to managers in quality reviews so that fixing them becomes planned work.
Open with
I would treat disabled tests as debt that needs an owner and a date. The first step is measurement, because nobody acts on a number they cannot see.
Then, if they want more
Our builds already write JUnit XML with every skipped test and its reason, so I would collect that from every main-branch build into one store and show, per team, how many tests are disabled or aborted and how old they are.
Then the policy: every @Disabled must carry a reason with a ticket key, which JUnit supports through the annotation's value, and a build check rejects a bare @Disabled in new code.
Anything disabled for more than about 90 days must be fixed or deleted, and deletion is fine, but it needs the owning team's approval so it is a decision, not neglect. I would separate legitimate environment conditions, like a Windows-only test, from tests that hide bugs; conditions are allowed as long as some CI job actually runs the test.
For the existing thousands I would not switch everything on at once: publish the numbers first, grandfather the backlog with per-team targets, and enforce the rules for new cases immediately.
Finally I would put the numbers in the quality review that engineering managers attend, because making room for this work is their decision, not something a single developer can do alone.
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
- 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 "Across your organisation, thousands of tests are disabled with @Disabled, conditional...": https://scrivio-interview-library.netlify.app/java/junit/c86951f14f/