The AI Wrote the Tests Too. Who's Testing the Tests?

When AI writes the code and the tests, coverage can look perfect while the suite locks bugs in. Mutation testing and spec-first tests show the gap.

The AI Wrote the Tests Too. Who's Testing the Tests?

In October, researchers at the University of Luxembourg had an AI model write regression tests for 145 real pull requests in SciPy, Qiskit and pandas. They then checked those tests using a pool of 60,780 deliberately injected faults.

Between 8.4% and 16.9% of the generated tests passed on the faulty code and failed on the corrected code. They asserted the bug as correct. Only 2.4% to 4.8% caught a fault. Depending on the project, tests that defended a bug outnumbered tests that caught one by roughly 3.5 to 6.5 times (Charoosaei, Richter and Papadakis, arXiv, Oct 2026).

It is a preprint. It used one model, Claude Haiku 4.5, and the faults were artificial. But it puts a number on something many teams already suspect: a green, high-coverage suite written by the same AI that wrote the code can tell you very little about whether the code is right.

Tests written from the code confirm the code

AI test generation is now normal. In Sonar's survey of 1,026 developers and engineering managers who use AI coding tools at work (fieldwork September 2026), 84% of teams use AI to generate tests, up from 75% a year earlier. Of those, 73% rate it very or extremely effective. Only 39% completely agree that AI-generated code is always checked before it is committed, and 76% say they generate AI code faster than they can verify it (Sonar, Nov 2026).

The trouble is where the tests come from. A test derived from the implementation shares the implementation's blind spots.

A second Luxembourg study, published in July 2026, compared two workflows across five models. When one model wrote the code and then wrote tests for it in the same session, fault detection was about 14%. When tests were generated from the task description in a fresh session, it was about 25%. The spec-first workflow won for all five models, by 11.7 points on average (Konstantinou, Tambon and Papadakis, arXiv, Jul 2026).

Three details from that study matter for anyone setting process:

  • Adding the implementation to the test-generation prompt cut fault detection by 9.1% to 18.2%, depending on the model.
  • Chain-of-thought prompting did not remove the bias. It produced more tests, not more caught faults.
  • Statement coverage ran from roughly 83% to 99% and showed no consistent relationship with fault detection.

Coverage can't see the tests that matter

Meta reached a similar conclusion from the other direction. Its mutation-guided test generator, ACH, produced 571 tests that caught injected faults on Android code. 277 of them, 49%, added no line coverage at all. A coverage gate would have scored half the useful tests as worthless. Meta's earlier coverage-targeted tool caught 2% of the injected faults; ACH caught about 12%. The authors' conclusion: "targeting coverage will be inadequate to kill mutants" (Meta, FSE 2025).

The gap can be extreme. In one example from a February 2026 paper, LLM-written tests reached 100% line and branch coverage and a mutation score of 4% (Wang, Xu, Briand and Liu, arXiv, Feb 2026).

This is not a story about AI tests being worse than human ones. In that same paper, plain LLM tests scored higher on mutation testing than EvoSuite, a long-established automated generator. A University of Tennessee preprint found AI-written tests caught 69% of 29 real Python bugs, against 17.2% for the projects' existing human-written tests (Vathana et al., arXiv, Jun 2026). But the AI in that study was given context about the bug, including its fix. That arguably supports the point: those tests had information about intended behavior, which the code alone cannot supply.

Even mutation scores flatter AI tests. An October 2026 study of 14,320 tests from four current models found a "happy-path bias". Null inputs were covered 34.8% of the time, negative inputs 23.8% and empty inputs 38.8%, and 15.6% of test failures came from assertions that contradicted the correct implementation. PIT mutation kill rates "far exceed" the authors' stricter per-construct scores, "making a PIT-only evaluation systematically overconfident" (Shi et al., arXiv, Oct 2026).

The suite that fights the fix

Here is how that plays out. This is an illustrative scenario, not a client case.

An AI agent builds a volume-discount rule and writes its tests. It gets a boundary wrong: an order of exactly $500 should qualify and doesn't. The agent writes tests from what its code returns, so one test asserts that a $500 order gets no discount. Coverage is 100%. CI is green. The pull request is approved.

Six months later, someone notices the discount problem and fixes the comparison. The suite goes red. The correct fix now looks like a regression, and the cheapest way to get back to green is to "update the test" or revert the fix.

The Luxembourg regression study measured how long these tests survive. 83% to 91% of the bug-enforcing tests still accepted their fault at the end of the studied commit history. The projects' own developer-written suites caught the propagated fault in only 6.1% to 36.3% of cases. The authors call unvalidated LLM regression tests "a new form of technical debt."

Our view is that the same risk applies in modernization work. Characterization tests generated from legacy code deliberately pin current behavior, bugs included. That is fine for a like-for-like port, as long as the known bugs are labeled as bugs. Otherwise they quietly become requirements of the new system.

What works

None of this means stop using AI for tests. It means aiming the AI at faults and specifications instead of at coverage.

Meta reports that its per-change LLM tests, which treat each code change as a possible fault, caught 74 serious privacy bugs before they landed in the first half of 2026, with a 20% reduction in privacy incidents over the same period. Those figures are self-reported (Engineering at Meta, Oct 2026). Thoughtworks moved mutation testing to "Adopt" in its November 2026 Technology Radar, noting that as AI-generated code and tests multiply, coverage metrics become "easier to inflate with superficial tests that lack meaningful validation" (Thoughtworks). Mutation testing at scale is not new: Google has run it in code review across more than 1,000 projects, mutating only changed lines, and developers rated 82% of the surfaced results productive (Google, 2021).

What to change on Monday

  • Stop accepting coverage as proof of quality on AI-assisted work, from your own teams or from vendors. Ask for a mutation score on changed code, using tools such as Stryker, PIT, mutmut or cargo-mutants, scoped to core logic or to the diff to keep run times manageable.
  • Write tests from the requirement, not the code. Generate them from the acceptance criteria in a separate session or with a different agent, before or without the implementation.
  • Review assertions against the spec. For each expected value, someone checks it is what the requirement says, not just what the code returned.
  • When a correct fix breaks an AI-written test, investigate the test first. Make that an explicit review norm.
  • Label pinned legacy behavior. In modernization, mark which characterization tests capture known bugs, so the new system doesn't inherit them as requirements.

This is how we approach AI-assisted engineering with structured review: the AI writes plenty of code, and a human-owned spec decides what correct means. If you want a second opinion on what your test suite is actually telling you, talk to us at midrasolutions.com.

Planning a build like this?

Talk to our engineering team about custom systems, legacy modernization, and cloud architecture.

Get in Touch