Exploring Automated Assertion Generation via Large Language Models

断言 计算机科学 程序设计语言 软件工程
作者
Quanjun Zhang,Weifeng Sun,Chunrong Fang,Bowen Yu,H. Li,Meng Yan,Jianyi Zhou,Zhenyu Chen
出处
期刊:ACM Transactions on Software Engineering and Methodology [Association for Computing Machinery]
被引量:2
标识
DOI:10.1145/3699598
摘要

Unit testing aims to validate the correctness of software system units and has become an essential practice in software development and maintenance. However, it is incredibly time-consuming and labor-intensive for testing experts to write unit test cases manually, including test inputs ( i.e., prefixes) and test oracles ( i.e., assertions). Very recently, some techniques have been proposed to apply Large Language Models (LLMs) to generate unit assertions and have proven the potential in reducing manual testing efforts. However, there has been no systematic comparison of the effectiveness of these LLMs, and their pros and cons remain unexplored. To bridge this gap, we perform the first extensive study on applying various LLMs to automated assertion generation. The experimental results on two independent datasets show that studied LLMs outperform six state-of-the-art techniques with a prediction accuracy of 51.82% \(\sim\) 58.71% and 38.72% \(\sim\) 48.19%. The improvements achieve 29.60% and 12.47% on average. Besides, as a representative LLM, CodeT5 consistently outperforms all studied LLMs and all baselines on both datasets, with an average improvement of 13.85% and 26.64%, respectively. We also explore the performance of generated assertions in detecting real-world bugs, and find LLMs are able to detect 32 bugs from Defects4J on average, with an improvement of 52.38% against the most recent approach EditAS . Inspired by the findings, we construct a simplistic retrieval-and-repair-enhanced LLM-based approach by transforming the assertion generation problem into a program repair task for retrieved similar assertions. Surprisingly, such a simplistic approach can further improve the prediction accuracy of LLMs by 9.40% on average, leading to new records on both datasets. Besides, we provide additional discussions from different aspects ( e.g., the impact of assertion types and test lengths) to illustrate the capacity and limitations of LLM-based approaches. Finally, we further pinpoint various practical guidelines ( e.g., the improvement of multiple candidate assertions) for advanced LLM-based assertion generation in the near future. Overall, our work underscores the promising future of adopting off-the-shelf LLMs to generate accurate and meaningful assertions in real-world test cases and reduce the manual efforts of unit testing experts in practical scenarios.

科研通智能强力驱动
Strongly Powered by AbleSci AI
科研通是完全免费的文献互助平台,具备全网最快的应助速度,最高的求助完成率。 对每一个文献求助,科研通都将尽心尽力,给求助人一个满意的交代。
实时播报
淡然芝发布了新的文献求助10
刚刚
浮云寄川发布了新的文献求助10
1秒前
领导范儿应助红木白花采纳,获得10
1秒前
1秒前
1秒前
1秒前
怕黑以筠发布了新的文献求助10
2秒前
小青发布了新的文献求助10
2秒前
2秒前
wanci应助头发茂密的我采纳,获得10
2秒前
胡浩发布了新的文献求助10
3秒前
牛牛完成签到,获得积分10
3秒前
熊熊发布了新的文献求助10
3秒前
tt发布了新的文献求助10
4秒前
4秒前
大意的惊蛰完成签到,获得积分10
5秒前
molihuakai应助潜龙采纳,获得10
6秒前
牛牛发布了新的文献求助10
6秒前
没事哒完成签到,获得积分10
7秒前
7秒前
7秒前
xin完成签到,获得积分10
9秒前
常常完成签到,获得积分20
9秒前
9秒前
9秒前
ayam完成签到,获得积分10
10秒前
tt完成签到,获得积分10
10秒前
11秒前
11秒前
科研通AI6.2应助974采纳,获得10
11秒前
MJ发布了新的文献求助20
12秒前
充电宝应助zhhha采纳,获得10
12秒前
无花果应助vvv采纳,获得10
13秒前
13秒前
123发布了新的文献求助10
13秒前
13秒前
yiyiy发布了新的文献求助10
13秒前
L18101061321完成签到 ,获得积分10
13秒前
小然完成签到,获得积分10
14秒前
14秒前
高分求助中
(应助此贴封号)【重要!!请各用户(尤其是新用户)详细阅读】【科研通的精品贴汇总】 10000
The Organometallic Chemistry of the Transition Metals 800
Chemistry and Physics of Carbon Volume 18 800
The Organometallic Chemistry of the Transition Metals 800
Leading Academic-Practice Partnerships in Nursing and Healthcare: A Paradigm for Change 800
The formation of Australian attitudes towards China, 1918-1941 640
Signals, Systems, and Signal Processing 610
热门求助领域 (近24小时)
化学 材料科学 医学 生物 纳米技术 工程类 有机化学 化学工程 生物化学 计算机科学 物理 内科学 复合材料 催化作用 物理化学 光电子学 电极 细胞生物学 基因 无机化学
热门帖子
关注 科研通微信公众号,转发送积分 6438241
求助须知:如何正确求助?哪些是违规求助? 8252388
关于积分的说明 17560114
捐赠科研通 5496506
什么是DOI,文献DOI怎么找? 2898805
邀请新用户注册赠送积分活动 1875465
关于科研通互助平台的介绍 1716437