arXivDaily arXiv每日学术速递 周一至周五更新
感恩节,周五至周末无更新,大家顺遂。周一再来吧
arXiv 2511.01104cs.SEcs.CL
收藏

HarnessLLM:基于强化学习的自动测试套件生成

HarnessLLM: Automatic Testing Harness Generation via Reinforcement Learning

UC Santa Barbara(加州大学圣巴巴拉分校);MIT-IBM Watson AI Lab(麻省理工-IBM沃森人工智能实验室);MIT CSAIL(麻省理工CSAIL)

Yujian Liu, Jiabao Ji, Yang Zhang, Wenbo Guo, Tommi Jaakkola, Shiyu Chang

AI总结:

提出HarnessLLM两阶段训练流水线,利用SFT和RLVR训练LLM编写测试套件代码,在错误发现与测试多样性上优于传统方法,并提升代码生成性能。

摘要:

现有的基于LLM的自动测试生成方法主要生成输入和预期输出对,以对正确程序的预期行为进行分类。尽管简单直接,但这些方法生成的测试多样性有限,且无法提供足够的调试信息。我们提出了HarnessLLM,一个两阶段训练流水线,使LLM能够编写用于测试的套件代码。具体而言,LLM生成合成输入并验证观察到的输出的代码,从而允许复杂的测试用例和灵活的输出验证,如不变性检查。为此,我们采用SFT训练LLM,随后使用具有定制奖励设计的RLVR。实验表明,HarnessLLM在错误发现和测试策略多样性上优于基于输入输出的测试。通过将生成的测试用例作为推理阶段验证进行测试时扩展,HarnessLLM进一步提升了代码生成性能。代码见 https://github.com/UCSB-NLP-Chang/HarnessLLM.git。

英文摘要:

Existing LLM-based automatic test generation methods mainly produce input and expected output pairs to categorize the intended behavior of correct programs. Although straightforward, these methods have limited diversity in generated tests and cannot provide enough debugging information. We propose HarnessLLM, a two-stage training pipeline that enables LLMs to write harness code for testing. Particularly, LLMs generate code that synthesizes inputs and validates the observed outputs, allowing complex test cases and flexible output validation such as invariant checking. To achieve this, we train LLMs with SFT followed by RLVR with a customized reward design. Experiments show that HarnessLLM outperforms input-output-based testing in bug finding and testing strategy diversity. HarnessLLM further benefits the code generation performance through test-time scaling with our generated test cases as inference-phase validation. Our code is available at https://github.com/UCSB-NLP-Chang/HarnessLLM.git.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑