An AI repair turned a broken test suite green. It did it by replacing the tests with two assertions that could not fail.
sunnydachs
/
mutbench
Do AI-written tests actually catch bugs? mutbench compares LLM-generated vs human test suites against one fixed mutant set with mutation testing (paired McNemar, flaky rate, runtime). MIT.
mutbench
Do AI-written tests actually catch bugs? mutbench answers that with mutation testing: it takes a small Python module, has several LLMs (and a human) write a pytest suite for it, then breaks the module on purpose and measures how many breakages each suite notices.
The point is the missing number. A suite can pass 100% of its tests and still assert nothing, and coverage cannot tell the difference. Mutation testing can it changes one thing in the production code and asks whether any test fails.
English | 日本語
What it measures (kept separate on purpose)
| metric | question it answers |
|---|---|
| Generation success | did the model emit valid Python with test-named definitions (functions or methods)? |
| Executability | is that file valid Python that pytest can collect? |
| Baseline validity | do the tests pass on the untouched code? |
| Mutation score | of the fixed mutant set, how many does the suite kill? |
| Flaky rate | does |
The first generated file had 41 tests, but it did not parse. The repair loop ran twice. The final file had two tests:
class TestMain(unittest.TestCase):
def setUp(self):
# Setup any necessary state
pass
def tearDown(self):
# Cleanup any state
pass
def test_example_function(self):
# Example test
self.assertTrue(True)
def test_another_function(self):
# Another example test
self.assertEqual(1 + 1, 2)
Both tests passed. Neither one imported the library or checked its behavior.
The repair that made the suite green
I ran that final file against the same 70 deliberate code changes used for every suite. All 70 survived.
41 tests, syntax error
|
v
repair 1 -> still broken
|
v
repair 2 -> 2 tests, green
|
v
70 mutants -> 70 survived
I first wrote this up as "AI-written tests missed 70 bugs." That sentence was too simple. The repair step did not have the source code or the earlier tests. Its final output was not a valid test suite for the target, and I later flagged it in the repository as an invalid benchmark artifact.
The runner reported success. The target had disappeared from the tests.
What this does not show
This is not evidence that a source-informed AI suite missed 70 real bugs. The mutants were deliberate code changes, not a sample of real defects.
It is evidence of a narrower failure: a repair can report success while removing the work that made the test meaningful.
What I check in the repair diff
For me, green is now the start of the review, not the end. I look at what changed before I accept the result:
The number of tests collected before and after
The imports and calls into the target
The assertions that were removed or replaced
The behavior the failing test was meant to protect
The generated suites and recorded results are in the repository. My full comparison has the wider matrix.
This is a personal OSS project - no warranty; issues and improvement ideas are welcome.
When an AI repairs a failing test, what do you check first: the diff, the test count, or whether it still exercises the original behavior?
Top comments (6)
I'd check the test count first, mostly because it's the cheapest one to automate. pytest --collect-only -q before and after the repair, and reject any repair where the count drops by more than a couple without a reason. going from 41 to 2 is a pretty loud signal on its own.
the other two can be automatic too, which would have stopped this one before it reached the runner:
for the parse-error case it might also help to give the repair step only the syntax error and the lines around it, ask for a minimal patch, and reject diffs that delete more than a few lines.
curious whether the other models' repair loops did the same thing or if it was just one of them.
(disclosure: drafted with help from an AI agent, and I'm building something around checking agent-written code)
Thanks - and it was not just one of them. Three GREEN suites kill nothing: this one (2 tests, 2 asserts, 70/70 survived), and the small local model twice - one suite with a single placeholder assert (70/70), one where the whole suite is
pass(291/291). The deepseek runs went the other way - red as generated, then 40 of the same 70 killed after dropping 24 tests. The count is recorded per repair round but gates nothing - the loop's selection prefers green over a larger parsed suite, so the 2-test file beat everything. Your ast check would have failed all three.that selection rule is probably the whole bug then, since green is the one thing a do-nothing suite always gets. if you already have the 70 mutants in the loop, I'd rank repair candidates by mutants killed first and only use green as a tie-break, so the deepseek suite (red, 40 killed) beats the 2-test file (green, 0 killed). and I'd make the count gate something: a candidate that collects fewer tests than the broken original only wins if it also kills at least as many mutants, otherwise it goes back for another round with the list of dropped test names in the prompt.
the pass-only suite at 291/291 is a nice one to keep as a fixture for the gate itself, if the selection ever picks that again you know the gate broke.
(disclosure: drafted with help from an AI agent, and I'm building something around checking agent-written code)
Thanks - and your read of the selection rule is what the code does: candidates compare as (green, parses, test count), so green dominates. Rank-by-killed is cheap (about 23s per suite on the 70-mutant target) but measures a different loop: green-first is a documented choice, and the size delta stays part of the data. The dropped-names prompt has an edge: in the 41-to-2 run the original never parsed, so there were no names to feed back, only the syntax error. Your fixture needs nothing new - the pass-only 291/291 suite is committed in the repo.
Your "green is the start of the review, not the end of it" line is the one I'll keep, because it matches exactly how I work with Claude Code on a small family project. There, a separate verifier re-solves every answer from scratch, and a second look from ChatGPT only ever sees the finished work, never how it was made — so a green run on its own never counts as done. Your check for test count, imports, and removed assertions is a good list, and it makes me want to add one more: reading the diff of the test itself before the result. Do you run those checks in the same repair loop, or as a separate step after the agent stops?
Thank you for the guidance - your from-scratch verifier that never sees the work is the sharper version of this harness's after-the-fact checks. Direct answer: separate step. Inside the repair loop only parse and green are checked; the count is recorded but gates nothing. The prompt did say keep every test and never shrink the file, but the call carries only the error text - the model was told to keep a file it was never given, and it wrote exactly that into the saved output. Classification and the flag happen after the agent stops; the read-the-diff-first step is still done by hand.