Ockhamareto: Pareto-Gated Segment-Level Credit Assignment for Concise Unit-Test Generation with Reinforcement Learning

📄 arXiv: 2608.24473v1 📥 PDF

作者: Dong Huang, Mark Harman, Jie M. Zhang, Zhijiang Guo, Mingzhe Du, See Kiong Ng

分类: cs.SE, cs.CL

发布日期: 2026-08-25


💡 一句话要点

提出Ockhamareto以解决单元测试生成中的效率与有效性问题

🎯 匹配领域: 支柱二:RL算法与架构 (RL & Architecture)

关键词: 单元测试生成 帕累托最优 奥卡姆剃刀 强化学习 软件测试 自动化测试 测试优化

📋 核心要点

  1. 现有的单元测试生成方法在效率和有效性之间存在权衡,难以同时优化。
  2. Ockhamareto通过引入帕累托门控奖金和令牌级段信用,优化测试生成过程,旨在提高测试的有效性和减少测试数量。
  3. 在多个基准测试中,Ockhamareto在变异和覆盖率指标上均优于现有方法,且测试套件规模最小。

📝 摘要(中文)

我们介绍了Ockhamareto,这是一个基于奥卡姆剃刀原则和帕累托最优性的单次GRPO框架,用于单元测试的生成和选择。Ockhamareto的两个主要组成部分是:一是仅奖励在变异和测试数量空间中不被支配的回合的帕累托门控奖金;二是令牌级段信用,将每个测试的边际变异杀死归因于其单元测试块的令牌。在UnLeakedTestBench (ULT)上,Ockhamareto严格优于最强的RL基线MIST-RL,并在所有优化目标上均表现优越,捕获更多的bug(49.9%对31.3%的变异分数),使用更少的测试(平均2.60对4.67),从而实现每个测试的3.4倍权衡改善。

🔬 方法详解

问题定义:本论文旨在解决单元测试生成中的效率与有效性问题。现有方法往往无法在这两者之间取得良好的平衡,导致测试生成过程中的资源浪费和效果不佳。

核心思路:Ockhamareto的核心思路是结合帕累托最优性和奥卡姆剃刀原则,通过奖励不被支配的测试生成路径和精确归因来提升测试的有效性,同时减少所需测试数量。

技术框架:Ockhamareto的整体架构包括两个主要模块:帕累托门控奖金模块和令牌级段信用模块。前者负责评估和奖励有效的测试生成路径,后者则将测试的效果归因于具体的代码令牌,从而实现更精细的优化。

关键创新:Ockhamareto的主要创新在于引入了帕累托门控奖金和令牌级段信用,这与现有方法的简单奖励机制有本质区别,能够更有效地指导测试生成过程。

关键设计:在设计中,Ockhamareto采用了特定的损失函数来平衡变异和测试数量的权衡,同时在网络结构上进行了优化,以确保测试生成的高效性和有效性。

🖼️ 关键图片

fig_0
img_1
img_2

📊 实验亮点

Ockhamareto在多个基准测试中表现出色,严格优于最强的RL基线MIST-RL。在UnLeakedTestBench上,Ockhamareto捕获了49.9%的变异分数,相较于MIST-RL的31.3%有显著提升;同时,平均测试数量减少至2.60,较MIST-RL的4.67大幅降低,实现了3.4倍的每测试权衡改善。

🎯 应用场景

Ockhamareto在软件测试领域具有广泛的应用潜力,尤其是在自动化测试生成和选择方面。其优化的测试生成策略可以帮助开发者更高效地发现和修复软件中的bug,提高软件质量。此外,该方法的设计理念也可以扩展到其他需要平衡效率与效果的领域,如机器学习模型的训练和评估。

📄 摘要(原文)

We introduce \textbf{Ockhamareto}, a single-shot GRPO framework for unit-test generation and selection, based on the principles of \emph{Ockham's Razor} and \emph{Pareto Optimality}. Ockhamareto has two principal components: (i)~a \emph{Pareto-gated Bonus} that rewards only rollouts non-dominated in~(mutation, $-$#tests) space, and (ii)~\emph{Token-level Segment Credit}, which attributes each test's marginal mutation kills back to the tokens of its unit-test block. On the \emph{UnLeakedTestBench~(ULT)}, Ockhamareto \emph{strictly Pareto-dominates} the strongest RL baseline~(\emph{MIST-RL}). Furthermore, it dominates on {\em each and all} optimization objectives, catching more bugs ($49.9\%$ vs $31.3\%$ mutation score at $N{=}5$), using \emph{fewer} tests ($2.60$ vs $4.67$ on average), thereby achieving $3.4\times$ the per-test trade-off improvement. The advantage is found in all four benchmarks~(\emph{HumanEval+}, \emph{MBPP+}, \emph{CodeContests}, \emph{TestGenEval-Lite}): Ockhamareto leads both mutation and coverage metrics on every one, always with the smallest suite. Ockhamareto also outperforms the state-of-the-art at all model scales, adding $+30$--$35$~pp mutation at 4B, 9B, and 27B model sizes. We also show that the knee point of the optimal trade-off between efficiency and effectiveness on the Pareto front is not correlated with obvious more easily computed proxy metrics, such as function size. This finding motivates the Pareto front computation; it is needed to identify this crucial engineering trade-off for each function under test.