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

使用语言模型的自动化测试用例修复

Automated Test Case Repair Using Language Models

Ahmadreza Saboor Yaraghi, Darren Holden, Nafiseh Kahani, Lionel Briand

AI总结:

针对测试用例维护成本高、损坏测试用例影响开发流程的问题,提出基于预训练代码语言模型的TaRGET方法,通过两步微调流程实现自动化修复,在TaRBench基准上达66.1%精确匹配准确率,并提供实用指南与扩展性分析。

摘要:

通过测试确保软件系统质量至关重要,但维护测试用例面临重大挑战和成本。为与不断演进的被测系统保持一致而频繁更新测试用例,通常需要很高的复杂度和成本。此外,未修复的损坏测试用例可能降低测试套件质量,干扰软件开发流程,浪费开发人员时间。为应对这一挑战,我们提出TaRGET(Test Repair GEneraTor,测试修复生成器),一种利用预训练代码语言模型实现自动化测试用例修复的新方法。TaRGET将测试修复视为语言翻译任务,采用两步流程基于表征测试损坏的关键上下文数据微调语言模型。为评估该方法,我们引入TaRBench,一个覆盖59个开源项目中45,373个损坏测试修复的综合基准。结果表明TaRGET有效,精确匹配准确率达66.1%。此外,研究检验了TaRGET在不同测试修复场景下的有效性,提供了预测生成测试修复可靠性较低情况的实用指南,并探讨了项目特定数据是否始终需要用于微调以及该方法对新项目是否有效。

英文摘要:

Ensuring the quality of software systems through testing is essential, yet maintaining test cases poses significant challenges and costs. The need for frequent updates to align with the evolving system under test often entails high complexity and cost for maintaining these test cases. Further, unrepaired broken test cases can degrade test suite quality and disrupt the software development process, wasting developers' time. To address this challenge, we present TaRGET (Test Repair GEneraTor), a novel approach leveraging pre-trained code language models for automated test case repair. TaRGET treats test repair as a language translation task, employing a two-step process to fine-tune a language model based on essential context data characterizing the test breakage. To evaluate our approach, we introduce TaRBench, a comprehensive benchmark we developed covering 45,373 broken test repairs across 59 open-source projects. Our results demonstrate TaRGET's effectiveness, achieving a 66.1% exact match accuracy. Furthermore, our study examines the effectiveness of TaRGET across different test repair scenarios. We provide a practical guide to predict situations where the generated test repairs might be less reliable. We also explore whether project-specific data is always necessary for fine-tuning and if our approach can be effective on new projects.

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

↑