一句话:首次实证评估多种开源LLM在不同提示设置下的Java单元测试生成能力,并与GPT-4和Evosuite对比。
单元测试对验证软件组件正确性至关重要,但人工编写耗时且困难。LLM 为自动化单元测试生成提供了新途径,然而已有研究多关注闭源模型(如 ChatGPT、CodeX)和固定提示策略,尚未系统探索先进开源 LLM 在不同提示设置下的能力。本文开展首个针对性实证研究,基于 17 个 Java 项目、五个结构和参数量各异的开源 LLM,并采用综合评估指标,系统考察提示因素对生成效果的影响。研究还比较了开源 LLM 与商用 GPT-4 及传统 Evosuite 的表现,识别了基于 LLM 的单元测试生成局限,并据此给出一系列对未来研究和实践应用的启示。
Unit testing is an essential activity in software development for verifying the correctness of software components. However, manually writing unit tests is challenging and time-consuming. The emergence of Large Language Models (LLMs) offers a new direction for automating unit test generation. Existing research primarily focuses on closed-source LLMs (e.g., ChatGPT and CodeX) with fixed prompting strategies, leaving the capabilities of advanced open-source LLMs with various prompting settings unexplored. Particularly, open-source LLMs offer advantages in data privacy protection and have demonstrated superior performance in some tasks. Moreover, effective prompting is crucial for maximizing LLMs’ capabilities. In this paper, we conduct the first empirical study to fill this gap, based on 17 Java projects, five widely-used open-source LLMs with different structures and parameter sizes, and comprehensive evaluation metrics. Our findings highlight the significant influence of various prompt factors, show the performance of open-source LLMs compared to the commercial GPT-4 and the traditional Evosuite, and identify limitations in LLM-based unit test generation. We then derive a series of implications from our study to guide future research and practical use of LLM-based unit test generation.CCS CONCEPTS • Software and its engineering → Software testing and debugging.
DOI 原文 · arXiv · PDF(开放获取) · DBLP
@inproceedings{YangYGW0ZCZLW024,
title = {On the Evaluation of Large Language Models in Unit Test Generation},
author = {Lin Yang and Chen Yang and Shutao Gao and Weijing Wang and Bo Wang and Qihao Zhu and Xiao Chu and Jianyi Zhou and Guangtai Liang and Qianxiang Wang and Junjie Chen},
booktitle = {ASE},
year = {2024},
doi = {10.1145/3691620.3695529}
}