Escaping the Self-Repair Trap: Improving Test Oracle Generation via Dual-Context Awareness
A test oracle is the assertion at the end of a unit test, the line that decides whether the code did the right thing, and the popular way to get a model to write one is to run the test, show it the failure, and let it try again until it passes. That loop optimises a proxy: under repair pressure the model reaches for whatever is easiest to satisfy, walking a check on an exact count down to a check that the count is above zero and then to a check that the object exists at all. Scored by mutation testing — how many deliberately broken versions of the code the generated test actually catches — the loop raised the share of tests that pass by 11.8 points while dropping fault detection 5.3 points below the same model's un-repaired first answer, and the later in the loop a test first passed, the weaker it was. Deleting the loop and spending the tokens on context instead — a folded skeleton of the classes involved, plus the specific runtime values the model asks a debugger for — beat both, at about a quarter of the cost and a fifth of the wall-clock.