Fix test suite

Which automated tests can you delete without losing important coverage?

Deleting automated tests does not have to weaken coverage. A test that no longer verifies valid behaviour, merely duplicates other evidence, or has lost the team’s trust can slow the suite and obscure more important results. A safe decision cannot be based only on a test’s age or failure frequency. It needs a risk map and evidence of what remains covered after removal.

Why tests keep accumulating

Every new test has a clear creation point but may lack a scheduled review date without an agreement. A feature changes, the same rule is verified at three layers, and a temporary scenario stays in regression for years. Together, these tests extend execution time, complicate data preparation and create more results to evaluate.

When a suite becomes unstable, deleting its most frequent failures is tempting. That is a dangerous shortcut. An unstable result may indicate a defect in the test, an environment problem, or a real concurrency defect in the application. First measure which tests are flaky and why. Only then decide what they are worth.

Distinguish four reasons to act

Not every candidate belongs in the bin. Classify it by reason first:

Age alone proves nothing. A ten-year-old test for a critical calculation may still be valuable. A new test without a relevant assertion may not be.

Map coverage before deleting anything

For every candidate, record the risk, expected outcome, and other tests that provide the same or complementary evidence. A table with “risk, scenario, layer, owner and last useful finding” is enough to begin.

Then ask three questions:

  1. If this test disappears, which other test will reveal the same incorrect behaviour? A similar name is not enough. Compare the actual assertions.
  2. Is the current layer proportionate? Input combinations may be covered more cheaply by unit or API tests, while one end-to-end scenario retains evidence that the journey works as a whole.
  3. Does the risk still matter? The team may consciously accept a low-impact risk, just as it decides what is not worth automating.

If the map exposes a gap, create replacement coverage or explicitly accept the risk before removing the original scenario.

Choose keep, repair, replace or delete

Decision When it is appropriate
Keep The test protects a valid, material risk and provides unique, trustworthy evidence.
Repair The risk matters, but the test implementation is unstable or difficult to understand.
Replace The same evidence can be obtained more precisely, quickly, or at a more suitable layer.
Delete The expectation is obsolete, the evidence is demonstrably redundant, or the team has consciously decided that the risk no longer needs coverage.

A larger problem may require a decision to repair or rewrite the suite. Individual tests must still be judged by value. A mechanical rewrite carries old baggage into new code.

Remove tests in small, verifiable groups

Mark candidates with a reason and owner first. When uncertain, assess the risk before considering exclusion from routine runs for a limited period, monitor the related risk and set a date for the final decision. Permanent quarantine merely moves the problem out of the report.

Once approved, remove data, configuration and documentation used solely by the test. Do not leave commented-out code “just in case”. Version control provides recoverable history. Compare run time, the number of unclear failures, and critical-journey coverage after the change. If the suite starts growing without rules again, address why test suites become unreliable.

Similar steps do not establish identical coverage

Consider an illustrative shop with three discount-code tests. All open the basket and enter a code. Expected behaviour, rather than shared clicks, determines whether they are duplicates.

Test What it should detect Assessment before removal
A valid code for an eligible customer Correct calculation and display of the final price Move calculation combinations lower while retaining a check of the interface-to-result integration
The same code for an ineligible account Rejection of the discount according to the rules Not a duplicate of successful use, check the role and server decision
Another valid-code check with identical data and assertions The same outcome under the same conditions A deletion candidate once any other purpose or dependencies have been ruled out

When comparing tests, also check for differences in environment, browser or language. If one checks a supported configuration, a code-only comparison would lose that purpose. ISTQB’s traceability section recommends connecting tests to requirements and risks. An unknown purpose is a question for the owner, rather than evidence of no value.

A replacement must fail for the same reason

Before replacing an expensive scenario, check that its replacement verifies the correct outcome. A successful API status alone confirms neither price nor customer eligibility. A visible saved message may not prove persisted state either. Agree on the input, expectation and specific fault that both tests should detect.

In a safe environment, compare the original and replacement against valid and deliberately incorrect behaviour. For a calculation, this could be a controlled rule change in a separate working version. Check that the relevant assertion fails, rather than only environment setup. If the replacement misses the incorrect behaviour, postpone removal.

For suitable source code, mutation testing can help establish whether tests detect deliberate changes. This measures more than executed lines. Assess results carefully, however: an equivalent mutant may leave behaviour unchanged, so its survival alone does not establish a missing test. Do not turn a mutation score into an automatic deletion instruction.

Check removal in CI and shared data too

Before deleting a test, search for uses of shared fixtures, accounts, helpers and selection tags. Data created by one scenario may inadvertently prepare another. If removal exposes that dependency, fix preparation in the remaining test instead of relying on execution order.

After the change, check which tests CI actually selected and executed. A successful run with an unintentionally empty selection is not replacement coverage. Run the remaining tests without the removed scenario and verify reports and blocking rules. Keep the reason, approval, replacement evidence and change reference so that the team knows when to reconsider the decision.

A faster report alone does not prove a better suite

Compare the same product version, environment and parallel execution setup. Fewer tests may reduce work without shortening execution if the removed scenarios were not on the pipeline’s longest path. Also track manual diagnosis time and remaining risks.

According to Playwright Test’s documentation, a test that fails and then passes on retry is classified as flaky. A final green result does not erase the initial failure or establish replacement reliability. Python pytest-playwright follows its own test runner’s retry configuration and reporting. Assess this part of the comparison according to the tool in use.

What you gain

Removing unnecessary tests can simplify assessment and reduce maintenance effort. The team spends maintenance effort on tests that protect real risks and can explain why every removed scenario was replaced or no longer needed. Deletion becomes a controlled decision instead of tidying by instinct.

Next step

Start with the ten slowest, most frequently skipped, or most duplicated tests. Record the risk and replacement evidence for each before changing the code. Only then classify the candidates as tests to keep, repair, replace, or safely remove.

Related topics

You might also be interested in

Reliable results matter more than the number of tests

We measure instability, investigate likely causes of intermittent failures and stabilise the suite within the agreed scope.