When to Delete Tests Instead of Fixing Them, Agent Tests Too
Most QA teams treat tests as untouchable. You write them, maintain them and nurse them back when they break, and deleting one feels like weakening the suite on purpose. In practice I've seen that instinct do real damage: suites full of tests nobody trusts, slow pipelines, and a growing pile of skipped and commented-out checks that survive only because nobody wanted to remove them.
A test you can't trust isn't a safety net. It's noise. When a test fails, the first question should be "is this a real problem?" and not "is this one of the ones we ignore?" Once people start filtering results in their heads, the suite has lost its value. Deleting a test is a normal maintenance step, not a defeat.
Coding agents raise the stakes on both sides. They add tests quickly, including ones that only describe current behaviour and will never catch anything. And when asked to "fix the build," some will happily delete or skip whatever is in the way. Here's how I decide what to fix and what to remove, the traps that keep teams from deciding, and the rules I give agents so the decision stays with a person.
Learn Python, Behave, GitHub Copilot, APIs, and CI/CD by building a real framework you can finish in a weekend.
Signs a test has outlived its value
Broken tests break for different reasons, and the reason decides what happens next. A test failing because of a real regression is doing its job. These are the signals that point the other way:
- The behaviour no longer exists. An endpoint was removed, a workflow replaced. Updating the assertions misses the point. Ask whether the behaviour still matters, and if it doesn't, the test goes.
- It tests an implementation detail, not the contract. Exact error message wording, internal ID formats, field order. These break on refactors that change nothing for clients. Rewrite against the contract or delete.
- It duplicates coverage elsewhere. Three tests that each check a 401 for a missing token on the same endpoint are a maintenance cost with no return. Keep the clearest one, or merge them into a parametrized test. Using AI to spot redundant tests covers how to find these.
- It has been flaky with no owner. A flaky test nobody has claimed is one the team has already decided isn't worth fixing. Make that explicit: remove it and open a ticket to rewrite it properly if the coverage matters.
- It can't fail. This one has become more common with generated tests. Break the behaviour it claims to protect, or change the expected value, and see whether it goes red. If it never does, perhaps because it mocks the thing under test or asserts on a value it just read back, it protects nothing.
Traps that keep teams from deleting
Protecting the coverage number. Coverage tells you which lines ran, not whether the tests are meaningful. A slightly lower number from a suite you trust is better than a high one propped up by tests nobody believes.
"We might need it someday." If a behaviour matters enough to worry about, it deserves a reliable test. A flaky or outdated test wasn't protecting you anyway.
"Someone senior wrote it." Who wrote a test and how old it is say nothing about its value. The only question is whether it gives you a reliable signal today.
"Just skip it for now." A skipped test still appears in the suite and still implies coverage that isn't there. Use a skip only as a short, dated placeholder for a known infrastructure problem. If the date passes, it becomes a deletion or a rewrite.
A decision framework
When I review suspect tests, I go through five questions in order:
- Is the behaviour still part of the system? If not, delete. Nothing else to decide.
- Does it pass reliably? Look at its recent history across CI runs, not one local run. A test that fails intermittently gives you almost nothing to act on, because you can't tell a real failure from noise. Debugging a flaky API test that only fails in CI helps you tell an environment problem from a broken test.
- If it fails, is the failure meaningful? Run it on its own with verbose output. If the failure comes from the test's own setup (hardcoded data, timing, external state) rather than the API, you're looking at a rewrite at best.
- Is the coverage worth the upkeep? Auth, payments and data integrity are worth rewriting even when the current test is a mess. Edge cases that no longer matter often aren't. Involve the feature owner in this decision.
- Does another test already cover it? If so, deleting it leaves no gap.
Record each deletion in one line in the commit or PR: "deleted: endpoint removed in v3" or "deleted: duplicate of test_missing_token_returns_401." It takes seconds and answers the "why is this gone?" question later, including when someone searches the git history after a regression.
Deletion stays a human decision
Ask a coding agent to "make CI green" and you may get exactly that, through a deleted test, a new skip marker or a loosened assertion. The agent isn't being sneaky. It's doing what it was asked. So I make the rule explicit in the repository instruction file, such as .github/copilot-instructions.md:
## Failing tests
- Never delete a test, add skip/xfail, or loosen an assertion to get a pass.
- If you believe a test is obsolete, duplicated, or cannot fail, say so in your
summary with evidence (the removed endpoint, the duplicate test name, or the
change you made that the test did not catch). A person decides.
That turns the agent into a useful scout. It's good at the legwork: finding tests for removed endpoints, listing duplicates, running the "can this fail?" check across a module. The decision and the commit stay with a person. In review, any diff that removes a test function or adds a skip gets a careful read, whoever wrote it.
Tests of LLM features: change the check, don't delete it
A newer case looks like flakiness but isn't. A test of a feature that calls a language model may pass on most runs and fail on some, because the output really does vary. Deleting it throws away useful coverage, and adding retries hides real regressions. Retrying without hiding real failures explains why blind retries are risky.
The better fix is to change what the test asserts. Check structure exactly, since a malformed response is a bug every time. Run content checks several times and assert on the pass rate against a threshold the team agrees on and records next to the test. Then a dropping pass rate is a signal you can act on, not noise you learn to ignore.
The aim of maintenance isn't more tests. It's a better signal. Every noisy test you remove makes the rest more trustworthy. If you want to build a suite where that's the default, with Copilot helping and not making the calls, my API testing courses cover it.