arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2510.08720cs.CL
收藏

生成多少代码和测试用例足够?从二进制矩阵视角评估测试用例生成

How Many Code and Test Cases Are Enough? Evaluating Test Cases Generation from a Binary-Matrix Perspective

Harbin Institute of Technology(哈尔滨工业大学);Central South University(中南大学);Chinese Academy of Sciences(中国科学院);Peking University(北京大学);Beijing University of Posts and Telecommunications(北京邮电大学)

Xianzhen Luo, Jinyang Huang, Wenzhen Zheng, Qingfu Zhu, Mingzheng Xu, Yiheng Xu, Yuantao Fan, Wanxiang Che

AI总结:

本文从二进制矩阵视角评估测试用例生成,提出TC-Bench基准,通过寻找最优诊断基来确定最小错误代码和测试用例集,揭示现有方法在诊断能力上的不足。

摘要:

评估由大型语言模型(LLMs)自动生成的测试用例是一项关键且具有挑战性的任务。现有基准常在大规模无结构错误代码集合上评估排除率,面临高计算成本和评分通胀问题。此外,它们无意中奖励能够检测常见简单错误的生成器,而无法惩罚其无法识别罕见但关键故障的能力。本文连接两个基本问题:(1)什么是最小的错误代码集足以代表整个错误空间?(2)什么是最小的测试用例集能区分它们?我们引入了一个新的框架,将基准构建正式化为在二进制代码-测试用例矩阵中寻找最优诊断基,其中行代表错误代码,列代表测试用例结果。该矩阵的秩指定最小的独立错误模式(错误代码)数量,并提供完整故障覆盖所需测试用例数量的紧上界。我们的目标是识别一个大小等于矩阵秩的基,以最大化内部多样性。为解决此NP难问题,我们提出WrongSelect,一种高效的近似算法来选择最大化多样性的错误代码。将此框架应用于数百万个编程竞赛提交,我们构建了TC-Bench,一个紧凑、多样且抗通胀的基准。大量实验表明,即使最先进的测试用例生成方法在TC-Bench上也仅能达到约60%的排除率,揭示了现有方法在诊断能力上的显著差距,并突显了未来改进的巨大空间。我们的数据集可在:https://huggingface.co/datasets/Luoberta/TC-Bench 和我们的代码在:https://github.com/Luowaterbi/TC-Bench。

英文摘要:

Evaluating test cases automatically generated by Large Language Models (LLMs) is a critical yet challenging task. Existing benchmarks often evaluate the exclusion ratio on large, unstructured collections of wrong codes, suffering from high computational costs and score inflation. Furthermore, they inadvertently reward generators that detect common, trivial bugs, while failing to penalize their inability to identify rare yet critical faults. In this work, we connect two fundamental questions: (1) What is the minimal set of wrong codes sufficient to represent the entire error space? and (2) What is the minimal set of test cases needed to distinguish them? We introduce a novel framework that formalizes benchmark construction as finding an optimal diagnostic basis in a binary code-test matrix, where rows represent wrong codes and columns represent test case results. The rank of this matrix specifies the minimal number of independent error patterns (wrong codes) and provides a tight upper bound on the number of test cases required for complete fault coverage. Our objective is to identify a basis of size equal to the matrix rank that maximizes internal diversity. To tackle this NP-hard problem, we propose WrongSelect, an efficient approximation algorithm to select maximally diverse wrong codes. Applying this framework to millions of competitive programming submissions, we construct TC-Bench, a compact, diverse, and inflation-resistant benchmark. Extensive experiments show that even the most advanced test case generation methods achieve only ~60% exclusion rates on TC-Bench, exposing a significant gap in their diagnostic power and highlighting substantial room for future improvement. Our dataset is available at: https://huggingface.co/datasets/Luoberta/TC-Bench and our code is at: https://github.com/Luowaterbi/TC-Bench.

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

↑