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

ChatUniTest:一个基于大语言模型的测试生成框架

ChatUniTest: A Framework for LLM-Based Test Generation

Yinghao Chen, Zehao Hu, Chen Zhi, Junxiao Han, Shuiguang Deng, Jianwei Yin

AI总结:

本文提出基于大语言模型的单元测试生成框架ChatUniTest,通过自适应焦点上下文和生成-验证-修复机制提升测试准确性,并在多个项目中取得最高总体行覆盖率。

摘要:

单元测试是一项必不可少但往往十分繁重的任务。为了缓解这一挑战,人们已经引入了多种自动化单元测试生成工具。值得注意的是,近年来基于大语言模型(LLMs)的方法引起了广泛关注,并展现出有前景的结果。然而,基于大语言模型的工具在生成准确的单元测试方面仍存在局限性。本文提出了ChatUniTest,一个基于大语言模型的自动化单元测试生成框架。ChatUniTest融合了自适应焦点上下文机制,以在提示中涵盖有价值的上下文,并遵循生成-验证-修复机制来纠正所生成单元测试中的错误。随后,我们开发了ChatUniTest Core,这是一个实现核心工作流的通用库,并辅以ChatUniTest Toolchain,这是一套无缝集成的工具,用于增强ChatUniTest的能力。我们的有效性评估表明,ChatUniTest在一半的评估项目中优于TestSpark和EvoSuite,实现了最高的总体行覆盖率。此外,来自我们用户研究的见解证实,ChatUniTest为软件测试领域的各类利益相关者提供了显著价值。ChatUniTest可在https://github.com/ZJU-ACES-ISE/ChatUniTest获取,演示视频可在https://www.youtube.com/watch?v=GmfxQUqm2ZQ观看。

英文摘要:

Unit testing is an essential yet frequently arduous task. Various automated unit test generation tools have been introduced to mitigate this challenge. Notably, methods based on large language models (LLMs) have garnered considerable attention and exhibited promising results in recent years. Nevertheless, LLM-based tools encounter limitations in generating accurate unit tests. This paper presents ChatUniTest, an LLM-based automated unit test generation framework. ChatUniTest incorporates an adaptive focal context mechanism to encompass valuable context in prompts and adheres to a generation-validation-repair mechanism to rectify errors in generated unit tests. Subsequently, we have developed ChatUniTest Core, a common library that implements core workflow, complemented by the ChatUniTest Toolchain, a suite of seamlessly integrated tools enhancing the capabilities of ChatUniTest. Our effectiveness evaluation reveals that ChatUniTest outperforms TestSpark and EvoSuite in half of the evaluated projects, achieving the highest overall line coverage. Furthermore, insights from our user study affirm that ChatUniTest delivers substantial value to various stakeholders in the software testing domain. ChatUniTest is available at https://github.com/ZJU-ACES-ISE/ChatUniTest, and the demo video is available at https://www.youtube.com/watch?v=GmfxQUqm2ZQ.

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

↑