Are Unit Tests Dead?

engineering · ai · 10 min

An engineer ran 444 agent coding runs, banned his agents from writing tests, and found the tests were not doing anything. The twist: this does not mean you need fewer tests. It means you need different ones.

Here is the tweet that started all of this. Kun Chen (@kunchenguid) builds the DeepSWE eval: 111 real-world coding tasks, run 444 times through Claude Sonnet 5.5. One arm of the experiment told the agent it was allowed to write tests. The other arm banned it from writing any tests at all.

Then he compared the two arms. Tap to zoom the gaps.

The experiment: tests allowed vs no tests

Same tasks, same model. The only difference: one side could write tests, the other could not.

Tasks solved
tests allowed
no tests written
Agent time
tests allowed
no tests written
Spend
tests allowed
no tests written
The success rate barely moved. The bill did. Banning test-writing changed task success by +0.9 points (too small to be real) while cutting time 6% and spend 9% (both real).

Source: kunchenguid's post, Oct 2026. 444 runs on Claude Sonnet 5.5 across 111 real-world tasks. Of the tests written in the allowed arm, 65% were unit tests and 35% integration tests, and neither group helped.

His conclusion, blunt: tell your agents to stop writing tests by themselves. And do not ask them to do TDD either, he says he has data that it hurts.

But wait. Read the fine print before you delete your test folder. He banned the agent writing its own tests. He did not test human-written tests, and the eval had almost no end-to-end tests (17 of them versus 3,000+ unit and integration tests). So the honest headline is narrower: tests written by the same agent that wrote the code did not help.

The mirror problem

This is the core of the whole debate, and it is one picture. The agent reads your request and forms an interpretation of what you want. Then it writes the code from that interpretation. Then it writes the tests from that same interpretation. Both the code and the tests are downstream of the same brain reading.

Why self-written tests cannot catch misreading

Toggle between self-check and independent check.

YOUR INTENT final margin never negative AGENT'S READING margin = price minus discount CODE lets margin go negative on big discounts (the bug) TESTS written by the same agent, from the same reading checks the reading,
Self-check: 1,200 tests, all green. The bug ships anyway, because the tests checked the agent's reading of your request, not your request.

This is the "independent X-ray machine" argument from Zhouwei: what AI needs is requirement-level verification where the questions come from a different teacher, one who only looked at the curriculum and never saw the student's notes. Quentin Haenn calls the failure mode "AI slop": code that is syntactically valid but business-false. The test suite, written by the same agent, never thinks to cross-reference the two files.

Two camps

The internet has opinions. They fall into two camps, and both have a point.

CAMP ONE: UNIT TESTS ARE DEAD
CAMP TWO: TESTS MATTER MORE

The rogues gallery

Theory is nice. Here is what happens when nobody checks the checker.

What actually works

So the agent cannot grade its own homework. What can? The pattern that keeps showing up: separate the author from the checker. Kun Chen calls it adversarial review with author/reviewer isolation. Anthropic ships something similar: parallel reviewer agents that cross-check each other's findings.

The reviewer test

Two setups. One catches the bug.

AUTHOR AGENT writes code + tests believes its reading is correct REVIEWER AGENT sees notes + code inherits the same reading, same blind spot verdict: ships the bug SAME HALLUCINATION, CHECKING ITSELF
Closed loop: the reviewer reads the author's reasoning and nods along. One shared hallucination, two signatures.

Four more techniques worth knowing, tap each one.

The numbers

Feelings are nice. Measurements are better. Each card names its source.

1.7x
More issues in AI-co-authored PRs than human-only ones. Logic issues up 75%.
CodeRabbit, Dec 2025, 470 PRs
45%
Of AI-generated code fails secure-coding benchmarks. 2.74x the vulnerabilities of human code.
Veracode, 2025/2026
+4%
Teams using agents write more test code, with greater coverage. The composition shifts, not the volume.
GitKraken x GitClear, 2026
29%
Of developers trust AI code accuracy, even though 84% now use AI coding tools.
Stack Overflow survey, 2025
6.1 to 1.8%
Agent regression rate when given spec plus TDD as a dual contract. A 70% cut.
arXiv study, 2026
59%
Of hard benchmark problems had flawed tests. Even the test suites we grade agents on are suspect.
OpenAI SWE-bench finding, Feb 2026

The verdict

The middle position won this debate, and it was not close. Tests are more important in the agent era, not less. But they have to be a different kind of test: an independent check on the author's work, not a second draft of the author's thoughts.

The pyramid, flipped

The old pyramid said: lots of unit tests, a few e2e tests. Agents changed the cost curve, so the pyramid flips.

END-TO-END does the thing work for a real user? INTEGRATION do the pieces agree? UNIT
End-to-end first, because agents write and self-heal e2e tests cheaply. Unit tests last, as golden fixtures derived from real debugging sessions, not as fine-grained guesses the agent rarely gets wrong anyway.

After: the "inverted pyramid" position from the debate, and Kun Chen's own conclusion: unit tests written by the implementer sit "closer to source code than independent product proof." Requirement-anchored tests, written from the request before the agent starts, beat post-hoc tests every time.

DHH said the quiet part out loud in a post I saved last month: there is no future where you manually review every line of agent code. What replaces it is adversarial agent review, automated testing, and maybe a spot check. This whole post is the receipt for that sentence. The tests are not dead. The self-graded tests are.

Tests as an independent check on an author you don't fully trust will be the most valuable code you own.

Sources

Keep exploring