Manuscript Offprint

arXiv:2609.05879

Correct Tests Are Not Enough: Measuring and Training Oracle Conversion in Specification-Based Test Generation

Yunhao Liang, Chengguang Gan, Ruixuan Ying, Hanjun Wei, Zhe Cui, Shiwen Ni

YUNHAO LIANG, Chengdu Institute of Computer Applications, Chinese Academy of Sciences, China and University of Chinese Academy of Sciences, China

CHENGGUANG GAN, Independent Researcher, Japan

RUIXUAN YING, Institute of Multidisciplinary Research for Advanced Materials (IMRAM), Tohoku University, Japan

HANJUN WEI, University of Chinese Academy of Sciences, China

ZHE CUI, Chengdu Institute of Computer Applications, Chinese Academy of Sciences, China and University of Chinese Academy of Sciences, China

SHIWEN NI, Artificial Intelligence Research Institute, Shenzhen University of Advanced Technology, China

Generating tests from a natural-language specification requires both an input that exposes faulty behavior and a correct expected output. These requirements need not improve together: a model can increase test correctness by choosing easier inputs, or discover useful inputs whose expected outputs it cannot predict. We study this interaction through executable reward decomposition and suite-level oracle-conversion measurement. Our generator jointly emits five input-output tests in one response. During training, audited reference programs provide correctness feedback, while a fixed bank of faulty programs provides two utility signals: potential input kill and effective kill after checking the generated output. An additive GRPO objective preserves both signals without requiring execution at inference time. On an audited TC-Bench split with 506 training and 142 evaluation tasks, three independently trained Qwen3.5-9B runs at step 75 increase full-test correctness from 28.59% to 42.54%, input kill from 24.06% to 25.27%, and effective full kill from 12.23% to 14.15%. Matched 50-step ablations reveal a trade-off: removing kill rewards yields higher correctness and slightly higher full kill, but lowers input kill to 21.60%. A fixed-input source-oracle crossover on 64 training-pool tasks attributes the principal NoKill-to-FullKill difference to harder input selection rather than worse output prediction on identical inputs. These results identify oracle conversion as a measurable bottleneck and show the benefits and limits of preserving input-utility feedback in joint test generation.

CCS Concepts: • Software and its engineering → Software testing and debugging.

Additional Key Words and Phrases: test generation, test oracles, executable feedback, reinforcement learning, fault detection

1 Introduction

Tests written before an implementation must express intended behavior rather than merely reproduce the behavior of an existing program. This requirement makes specification-based test generation attractive for test-driven development: a developer supplies a programming requirement, and a model proposes inputs together with their expected outputs. The tests can then reject candidate implementations that violate the requirement. Unlike regression-test generation, this setting cannot assume that an implementation under test is already a trustworthy source of expected behavior. The distinction is an instance of the test-oracle problem [3], and it remains important when a language model produces the entire test.

Authors' Contact Information: Yunhao Liang, Chengdu Institute of Computer Applications, Chinese Academy of Sciences, China and University of Chinese Academy of Sciences, China; Chengguang Gan, Independent Researcher, Japan; Ruixuan Ying, Institute of Multidisciplinary Research for Advanced Materials (IMRAM), Tohoku University, Japan; Hanjun Wei, University of Chinese Academy of Sciences, China; Zhe Cui, Chengdu Institute of Computer Applications, Chinese Academy of Sciences, China and University of Chinese Academy of Sciences, China; Shiwen Ni, Artificial Intelligence Research Institute, Shenzhen University of Advanced Technology, China.

Automated testing has long separated input exploration from behavioral checking. Feedback-directed generation uses execution to identify useful input sequences [18]; whole-suite search and assertion generation use an implementation to construct regression tests [6]. Neural oracle generation addresses the complementary problem of inferring assertions from program context [5]. More recent systems combine language models with coverage feedback or execution-based filtering to improve tests for available code [1, 2]. In contrast, our deployment interface contains a natural-language statement and its input/output conventions, but no candidate implementation, reference solution, public input/output example, or interactive execution feedback. The output is a small complete test suite, not test code that requires a focal-method signature.

This interface creates two distinct opportunities for failure. A test can contain an incorrect expected output, even when its input is executable. It can also be entirely correct yet fail to distinguish any faulty program in the evaluation bank. These failures call for different learning signals. Rewarding only correctness can favor input distributions on which the model is comfortable computing outputs. Rewarding discriminative inputs can instead favor cases whose outputs require more difficult reasoning. When fault-detection credit is awarded only after the generated output is correct, a useful input with an incorrect output receives no direct credit for its latent value.

The tension itself is not new. UTGen explicitly studies the need to generate revealing inputs and accurate outputs without access to a gold implementation, and uses generated tests in automated debugging [19]. UTRL trains a tester with adversarial feedback from a coder [13], while CURE co-evolves coding and testing policies [24]. These methods establish the importance of discriminative test training. They leave room for a narrower empirical question: when an executable reward changes the inputs chosen by a joint test generator, how much of the resulting fault-detection opportunity survives the model's own expected outputs? A higher correctness rate alone cannot answer this question, and neither can an input-only kill score.

We address this question with oracle conversion: the extent to which potentially detectable faulty programs are actually detected by fully correct generated tests. For each task, we execute a generated input against audited reference programs to obtain a consensus output. The same input defines a set of faulty programs that it could distinguish with that output. Only tests whose generated outputs match the consensus contribute to effective detection. Taking unions within a suite avoids awarding repeated credit for detecting the same faulty program. The difference between potential and effective kill then quantifies lost opportunities; their suite-unique aggregate ratio measures conversion efficiency.

This accounting motivates a simple joint training objective, Additive GRPO. In addition to format, count, input-validity, and full-correctness rewards, it includes both effective full kill and potential input kill. The latter remains available when the input executes correctly but the model predicts the wrong output. All components are computed from programs during training. At inference, the trained policy emits five complete tests in a single response, without a selector or execution loop. The experimental focus is the allocation of executable reward and the behavior that it produces.

We evaluate Qwen3.5-9B on an audited TC-Bench subset [17]. The principal comparison uses one frozen Base output set and three independent training seeds. At step 75, Additive GRPO improves full correctness by 13.94 percentage points, potential input kill by 1.22 points, and effective full kill by 1.92 points. All three seeds improve these metrics relative to Base, although one seed's input-kill gain is only 0.02 points. The result is a joint improvement of modest utility magnitude, not a claim that reward decomposition eliminates the oracle problem.

The ablations explain why the distinction matters. At an equal 50-step training budget, NoKill reaches 47.04% full correctness and 14.36% full kill, both above Additive's 40.66% and 13.67%. Yet NoKill's input kill falls below Base in every seed. Additive preserves a higher mean input kill, but converts fewer of its opportunities. Thus, neither correctness nor input utility ranks the methods in the same way as effective detection. To separate input selection from oracle ability, we also cross three input-source policies with three output-prediction policies while holding the input bytes fixed. For the primary NoKill-to-FullKill contrast, output prediction improves on identical inputs, while the selected input distribution becomes harder. This rules out a simple account in which kill-oriented training merely damages all oracle prediction.

The paper makes three contributions:

  • A suite-unique oracle-conversion protocol that jointly reports test correctness, potential fault detection, effective fault detection, and the opportunities lost at the output stage.
  • A matched executable-reward study of joint test generation, including NoKill, FullKill-only, and Additive objectives, three independent seeds, and an optimizer-preserving training-length continuation.
  • A source-oracle crossover that separates the difficulty of chosen inputs from the ability to predict their outputs, a distinction hidden in aggregate test scores.

References (19)