有效的单元测试有助于保障和提升软件质量,但编写和维护单元测试需要投入大量时间和精力。一个单元测试由测试前缀和测试预言组成。合成测试预言,尤其是功能性预言,是一个公认的难题。近期研究提出利用神经模型生成测试预言,即神经测试预言生成(NTOG),并取得了有前景的结果。然而,经过系统性检查,我们发现现有 NTOG 评估方法中存在一些不恰当的设置。这些设置可能误导对现有 NTOG 方法性能的理解。我们将其总结为:1)从已修复缺陷的程序版本生成测试前缀;2)使用不切实际的指标进行评估;3)缺乏直接的基线方法。在本文中,我们首先研究这些设置对评估和理解 NTOG 方法性能的影响。我们发现:1)从已修复缺陷的程序版本不切实际地生成测试前缀,会使最先进的 NTOG 方法 TOGA 发现的缺陷数量膨胀 61.8%;2)FPR(假阳性率)不是一个切合实际的评估指标,TOGA 的 Precision 仅为 0.38%;3)一个直接的基线方法 NoException——它仅期望不应抛出异常——能够发现 TOGA 所发现缺陷的 61%,且 Precision 是 TOGA 的两倍。此外,我们在现有评估方法中引入了一个额外的排序步骤,并提出名为 Found@K 的评估指标,以更好地衡量 NTOG 方法的成本效益。我们提出一种新颖的无监督排序方法来实例化该排序步骤,显著提升了 TOGA 的成本效益。最终,我们为 NTOG 提出了一种更真实的评估方法 TEval+,并总结了七条经验法则,以推动 NTOG 方法走向实际应用。
英文摘要:
Effective unit tests can help guard and improve software quality but require a substantial amount of time and effort to write and maintain. A unit test consists of a test prefix and a test oracle. Synthesizing test oracles, especially functional oracles, is a well-known challenging problem. Recent studies proposed to leverage neural models to generate test oracles, i.e., neural test oracle generation (NTOG), and obtained promising results. However, after a systematic inspection, we find there are some inappropriate settings in existing evaluation methods for NTOG. These settings could mislead the understanding of existing NTOG approaches' performance. We summarize them as 1) generating test prefixes from bug-fixed program versions, 2) evaluating with an unrealistic metric, and 3) lacking a straightforward baseline. In this paper, we first investigate the impacts of these settings on evaluating and understanding the performance of NTOG approaches. We find that 1) unrealistically generating test prefixes from bug-fixed program versions inflates the number of bugs found by the state-of-the-art NTOG approach TOGA by 61.8%, 2) FPR (False Positive Rate) is not a realistic evaluation metric and the Precision of TOGA is only 0.38%, and 3) a straightforward baseline NoException, which simply expects no exception should be raised, can find 61% of the bugs found by TOGA with twice the Precision. Furthermore, we introduce an additional ranking step to existing evaluation methods and propose an evaluation metric named Found@K to better measure the cost-effectiveness of NTOG approaches. We propose a novel unsupervised ranking method to instantiate this ranking step, significantly improving the cost-effectiveness of TOGA. Eventually, we propose a more realistic evaluation method TEval+ for NTOG and summarize seven rules of thumb to boost NTOG approaches into their practical usages.
MASTOR: A Multi-Agent Approach to Semantic Test Oracle Generation for RESTful APIs
Macau University of Science and Technology(澳门科技大学);Macau University of Science and Technology Zhuhai MUST Science and Technology Research Institute(澳门科技大学珠海MUST科学技术研究院);Beihang University(北京航空航天大学);China University of Mining and Technology(中国矿业大学)
HistoryFinder: Advancing Method-Level Source Code History Generation with Accurate Oracles and Enhanced Algorithm
SQM Research Lab, University of Manitoba(马尼托巴大学 SQM 研究实验室);American International University-Bangladesh(孟加拉国美国国际大学);University of Saskatchewan(萨斯喀彻温大学)
Escaping the Self-Repair Trap: Improving Test Oracle Generation via Dual-Context Awareness
Beihang University(北京航空航天大学);National College for Excellent Engineers(卓越工程师学院);Qingdao Research Institute(青岛研究院);Hangzhou Innovation Institute(杭州创新研究院)
MANGO: Automated Multi-Agent Test Oracle Generation for Vision-Language-Action Models
Mondragon University(蒙得龙大学);Simula Research Laboratory(Simula研究实验室);University of Ottawa(渥太华大学);Research Ireland Lero Centre for Software(爱尔兰Lero软件研究中心)
Correct Tests Are Not Enough: Measuring and Training Oracle Conversion in Specification-Based Test Generation
Chengdu Institute of Computer Applications, Chinese Academy of Sciences(中国科学院成都计算机应用研究所);University of Chinese Academy of Sciences(中国科学院大学);Institute of Multidisciplinary Research for Advanced Materials (IMRAM), Tohoku University(东北大学先进材料多学科研究所);Artificial Intelligence Research Institute, Shenzhen University of Advanced Technology(深圳先进技术研究院人工智能研究所)
LLM-Based Test Generation: Information Sources, Generation Strategies, and Quality Evidence
Chengdu Institute of Computer Applications, Chinese Academy of Sciences(中国科学院成都计算机应用研究所);University of Chinese Academy of Sciences(中国科学院大学);Institute of Multidisciplinary Research for Advanced Materials (IMRAM), Tohoku University(东北大学先进材料多学科研究所);Artificial Intelligence Research Institute, Shenzhen University of Advanced Technology(深圳先进技术研究院人工智能研究所)
Auditing and Decomposing Feedback-Driven Evolution in LLM Test Generation under the Oracle Problem
Chengdu Institute of Computer Applications, Chinese Academy of Sciences(中国科学院成都计算机应用研究所);University of Chinese Academy of Sciences(中国科学院大学);Institute of Multidisciplinary Research for Advanced Materials (IMRAM), Tohoku University(东北大学先进材料多学科研究所);Artificial Intelligence Research Institute, Shenzhen University of Advanced Technology(深圳先进技术研究院人工智能研究所)
Automated Trustworthiness Oracle Generation for Machine Learning Text Classifiers
Monash University(莫纳什大学);University of Auckland(奥克兰大学);Royal Melbourne Institute of Technology(皇家墨尔本理工学院);Joint Research Centre at the European Commission(欧洲委员会联合研究中心)
DSCodeBench: A Realistic Benchmark for Data Science Code Generation
King’s College London(伦敦国王学院);Institute of Data Science, National University of Singapore(新加坡国立大学数据科学学院);Institute of Software Chinese Academy of Sciences(中国科学院软件研究所);Peking University(北京大学)
BackendForge: Benchmarking Agentic End-to-End Code Generation with Backend Services
Key Lab of HCST (PKU), MOE(北京大学计算机科学与技术国家重点实验室;软件学院,北京大学);SCS, Peking University(北京通明湖信息技术应用创新中心);Beijing Tongming Lake Information Technology Application Innovation Center (TLAIC)(复旦大学高级计算系统研究所);Fudan University Institute of Systems for Advanced Computing(上海开放计算系统研究所);Shanghai Institute of Systems for Open Computing