arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2408.07846cs.SEcs.AI
收藏

一种使用大语言模型自动生成单元测试并评估生成测试套件的系统

A System for Automated Unit Test Generation Using Large Language Models and Assessment of Generated Test Suites

Polytechnic University of Bari \& Wideverse Bari, Italy;Polytechnic University of Bari Bari, Italy;Independent Researcher;University of Bari Bari, Italy

Andrea Lops, Fedelucio Narducci, Azzurra Ragone, Michelantonio Trizio, Claudio Bartolini

AI总结:

针对现有LLM单元测试研究场景简单、规模不足、评估效率低的问题,提出自动化系统AgoneTest,实现类级测试套件生成与全流程评估,并构建新数据集支撑对比研究。

摘要:

单元测试是软件测试生命周期中最基础的测试层级,对保障软件正确性至关重要。设计与编写单元测试成本高昂且耗费人力,具备很高的自动化潜力。近年来,大语言模型(LLM)已被应用于软件开发的多个环节,其中包括单元测试生成。尽管已有多项实证研究评估LLM在测试代码生成方面的能力,但这些研究主要聚焦于简单场景,例如为单个方法直接生成单元测试。这类评估通常涉及独立的小规模测试单元,难以全面反映LLM在真实软件开发场景中的表现。此外,以往研究的问题规模并不适配实际应用场景。生成的单元测试往往需要通过手动集成到原始项目中的方式进行评估,这一过程限制了可执行的测试数量,降低了整体效率。为弥补这些研究空白,我们提出了一种生成并评估更具真实复杂度的测试套件的方法。该方法聚焦于类级别的测试代码生成,实现了从测试生成到测试评估的全流程自动化。在本研究中,我们提出了AgoneTest:一个用于为Java项目生成测试套件的自动化系统,以及一套全面且规范的生成测试套件评估方法。我们以前沿数据集Methods2Test为基础,构建了一个用于对比人工编写测试与LLM生成测试的新数据集。本文的核心贡献包括一个可扩展的自动化软件系统、一个新数据集,以及一套详细的测试质量评估方法。

英文摘要:

Unit tests represent the most basic level of testing within the software testing lifecycle and are crucial to ensuring software correctness. Designing and creating unit tests is a costly and labor-intensive process that is ripe for automation. Recently, Large Language Models (LLMs) have been applied to various aspects of software development, including unit test generation. Although several empirical studies evaluating LLMs' capabilities in test code generation exist, they primarily focus on simple scenarios, such as the straightforward generation of unit tests for individual methods. These evaluations often involve independent and small-scale test units, providing a limited view of LLMs' performance in real-world software development scenarios. Moreover, previous studies do not approach the problem at a suitable scale for real-life applications. Generated unit tests are often evaluated via manual integration into the original projects, a process that limits the number of tests executed and reduces overall efficiency. To address these gaps, we have developed an approach for generating and evaluating more real-life complexity test suites. Our approach focuses on class-level test code generation and automates the entire process from test generation to test assessment. In this work, we present AgoneTest: an automated system for generating test suites for Java projects and a comprehensive and principled methodology for evaluating the generated test suites. Starting from a state-of-the-art dataset (i.e., Methods2Test), we built a new dataset for comparing human-written tests with those generated by LLMs. Our key contributions include a scalable automated software system, a new dataset, and a detailed methodology for evaluating test quality.

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

↑