Journal 6 min

A passing test says little

When an agent writes both the code and the tests, a passing test proves little. What I think has to hold before the word "done" is accepted.

When an agent writes the code, then the tests, and the tests pass, I conclude almost nothing. The reason is who wrote what. A test is supposed to be a second opinion on the code. If one model writes both in one session, from one understanding of the request, the second opinion repeats the first. We even know which way it leans: tests generated by a model tend to assert what the code does rather than what it should do (Konstantinou, Degiovanni and Papadakis, 2024). A bug in the code ends up written down in the test as the expected behaviour, and everything is green.

”Done” is a statement about the request

What bothers me most in an agent’s report is that the word “done” and the line “42 tests pass” sit next to each other as if one followed from the other. They are about different things. “Done” means that what was asked has been delivered. “42 tests pass” means that 42 statements about the code are true, and nobody knows which of them concern the request. Take a plain request: a password that contains the username must be rejected. The agent can deliver 42 tests about length, special characters and the error message, all green, without one of them trying “alice” with the password “alice2026”. For the two sentences to meet, the request has to exist somewhere in a form you can point at, a list of requirements each with a name, and every test has to say which one it verifies. Only then can you ask the question that matters: for each thing that was asked, does a test verify it? A requirement with no test is not necessarily badly implemented. We simply do not know, and in that case I would rather the report said so.

That link between a test and a requirement has a lifespan, which is the part people forget most easily. Requirements get reworded. The name stays, a condition changes, or a threshold, or an edge case, and the tests written for the old sentence keep passing. They are green for a question nobody is asking any more. Nothing breaks and no report moves, so nobody has a reason to go and look. I think a change of meaning should void the earlier greens outright, until someone has reread each test involved and confirmed it still answers the right question. It is tedious, I know. I still prefer that rereading, done on the day you remember what you just changed, to an investigation three months later into behaviour every test declared correct.

Evidence is something that ran

An agent is very good at writing sentences like “I verified that the empty case is handled”. I have stopped reading those as information. Most of them are true. I just have no way to tell the true ones from the others, and a statement I cannot tell apart from a false one teaches me nothing. The same goes for a test that exists in the repository but that the runner never executes, or for a comment saying a case is covered. What counts as evidence, to me, is the trace of an execution: this test ran, at this time, on this code, and it passed.

So the final check should not be delivered by a model. I want to rerun it on the same files and get the same verdict, and a model asked twice about the same diff can give two opinions. A model is useful upstream, to propose things: a way to break the code, a twisted input, a reading of an ambiguous requirement. But a proposal gets confirmed by running it. If a model says a test is weak, you build the faulty code and see whether the test lets it through. If it says a test is good, that clears nothing. A model’s judgment on its own should neither block nor approve. You will tell me that review by a second model catches real bugs, and it does. I am happy to keep it as a source of hypotheses. I only refuse to make it the last step, the one after which nobody looks.

You have to watch a test fail

We usually judge a test on the correct code: it passes, good. But a test that asserts nothing passes too, and a test that copies the code’s output passes by construction. What I want to know is whether this test would notice the code breaking the requirement, and the only way to find out is to try. For the password rule from earlier, you write a version of the code that accepts “alice2026” for alice, or one that compares case-sensitively and so lets “Alice2026” through, and you run the tests that claim to cover the rule. If they stay green they were covering nothing, however many of them there are.

When an agent is the one writing the tests, there is one more precaution to take: it must not see the broken code. Show it the faulty variant and it writes a test cut to fit, the check goes green again, and you have learned nothing about the violations you did not show it. What you can give it is the name of the requirement and an input its tests fail to tell apart. Working out why is its job. It is the same logic as a test set kept away from training: once the one being graded has seen the answer sheet, the grade means nothing. The Claude Code team puts it this way for review rules in their post on verification: if a change can modify the check that judges it, the check is broken. I agree, and I think it extends to everything the agent can observe about the check, beyond what it can modify.

Knowing when to stop the loop

All of this runs as a loop: the check refuses, hands back its findings, the agent fixes, and round it goes. As long as each round makes progress, that is fine, and cheap. But an agent blocked several times in a row on the same finding does not start thinking harder, it starts looking for whatever silences the check. I stop at three refusals without progress. By then either the requirement is badly written, or it contradicts another one, or the check itself is wrong, and insisting settles none of those. Someone has to look. The Claude Code team’s post sets the same limit, three rounds and then a human, and uses it to pick what a person should go and look at, since nobody can read every change. Their first principle is a different one: run the application end to end, which to them matters more than tests.

What I do not know how to do

A test tied to a requirement, executed, and failing on a faulty variant can still miss what matters: it fails on the violation someone thought to build, and says nothing about the others. And at the very bottom of the ladder, a correctly labelled test that asserts nothing satisfies the simplest part of the check. Saying whether a test is worth anything is still review work, done by someone who knows the request. I do not know how to make it mechanical all the way down.