A Large-Scale Empirical Study on Fine-Tuning Large Language Models for Unit Testing
Proceedings of the ACM on Software Engineering · 22.06.2025 · 2 (ISSTA) · 1678-1700
DOI: 10.1145/3728951 ↗Kurz gefasst
Fachartikel in der Zeitschrift Proceedings of the ACM on Software Engineering, online erschienen am 22.06.2025. Verfasst von Ye Shang und 5 weiteren Autor:innen. Die Arbeit wurde bisher 27-mal zitiert (Crossref) und nennt 66 Literaturangaben. Der Volltext ist frei zugänglich (Open Access, CC BY 4.0). Gefördert von: National Natural Science Foundation of China, CCF-Huawei Populus Grove Fund, Science, Technology and Innovation Commission of Shenzhen Municipality.
Abstract (Originalsprache)
Unit testing plays a pivotal role in software development, improving software quality and reliability. However, generating effective test cases manually is time-consuming, prompting interest in unit testing research. Recently, Large Language Models (LLMs) have shown potential in various unit testing tasks, including test generation, assertion generation, and test evolution, but existing studies are limited in scope and lack a systematic evaluation of the effectiveness of LLMs. To bridge this gap, we present a large-scale empirical study on fine-tuning LLMs for unit testing. Our study involves three unit testing tasks, five benchmarks, eight evaluation metrics, and 37 popular LLMs across various architectures and sizes, consuming over 3,000 NVIDIA A100 GPU hours. We focus on three key research questions: (1) the performance of LLMs compared to state-of-the-art methods, (2) the impact of different factors on LLM performance, and (3) the effectiveness of fine-tuning versus prompt engineering. Our findings reveal that LLMs outperform existing state-of-the-art approaches on all three unit testing tasks across nearly all metrics, highlighting the potential of fine-tuning LLMs in unit testing tasks. Furthermore, large-scale, decoder-only models achieve the best results across tasks, while encoder-decoder models perform better under the same parameter scale. Additionally, the comparison of the performance between fine-tuning and prompt engineering approaches reveals the considerable potential capability of the prompt engineering approach in unit testing tasks. We then discuss the concerned issues on the test generation task, including data leakage issues, bug detection capabilities, and metrics comparisons. Finally, we further pinpoint carious practical guidelines for LLM-based approaches to unit testing tasks in the near future. Overall, our work demonstrates the promising future of fine-tuning LLMs on unit testing tasks and reduces the manual efforts of unit testing experts in practical scenarios.
Förderung
- National Natural Science Foundation of China
- CCF-Huawei Populus Grove Fund
- Science, Technology and Innovation Commission of Shenzhen Municipality
Zitieren
APA
Shang, Y., Zhang, Q., Fang, C., Gu, S., Zhou, J., & Chen, Z. (2025). A Large-Scale Empirical Study on Fine-Tuning Large Language Models for Unit Testing. Proceedings of the ACM on Software Engineering, 2(ISSTA), 1678-1700. https://doi.org/10.1145/3728951
Vancouver
Shang Y, Zhang Q, Fang C, Gu S, Zhou J, Chen Z. A Large-Scale Empirical Study on Fine-Tuning Large Language Models for Unit Testing. Proceedings of the ACM on Software Engineering. 2025;2(ISSTA):1678-1700. doi:10.1145/3728951
BibTeX
@article{Shang2025,
author = {Shang, Ye and Zhang, Quanjun and Fang, Chunrong and Gu, Siqi and Zhou, Jianyi and Chen, Zhenyu},
title = {A Large-Scale Empirical Study on Fine-Tuning Large Language Models for Unit Testing},
journal = {Proceedings of the ACM on Software Engineering},
year = {2025},
volume = {2},
number = {ISSTA},
pages = {1678--1700},
doi = {10.1145/3728951}
}
EUVIMED