清晨好,您是今天最早来到科研通的研友!由于当前在线用户较少,发布求助请尽量完整的填写文献信息,科研通机器人24小时在线,伴您科研之路漫漫前行!

No More Manual Tests? Evaluating and Improving ChatGPT for Unit Test Generation

正确性 可读性 单元测试 计算机科学 可用性 质量(理念) 考试(生物学) 代码覆盖率 发电机(电路理论) 测试用例 关键字驱动测试 可靠性工程 机器学习 软件工程 程序设计语言 软件 人机交互 工程类 软件开发 物理 古生物学 软件建设 哲学 功率(物理) 回归分析 认识论 量子力学 生物
作者
Zhiqiang Yuan,Yiling Lou,Mingwei Liu,Shiji Ding,Kaixin Wang,Yixuan Chen,Xin Peng
出处
期刊:Cornell University - arXiv 被引量:36
标识
DOI:10.48550/arxiv.2305.04207
摘要

Unit testing is essential in detecting bugs in functionally-discrete program units. Manually writing high-quality unit tests is time-consuming and laborious. Although traditional techniques can generate tests with reasonable coverage, they exhibit low readability and cannot be directly adopted by developers. Recent work has shown the large potential of large language models (LLMs) in unit test generation, which can generate more human-like and meaningful test code. ChatGPT, the latest LLM incorporating instruction tuning and reinforcement learning, has performed well in various domains. However, It remains unclear how effective ChatGPT is in unit test generation. In this work, we perform the first empirical study to evaluate ChatGPT's capability of unit test generation. Specifically, we conduct a quantitative analysis and a user study to systematically investigate the quality of its generated tests regarding the correctness, sufficiency, readability, and usability. The tests generated by ChatGPT still suffer from correctness issues, including diverse compilation errors and execution failures. Still, the passing tests generated by ChatGPT resemble manually-written tests by achieving comparable coverage, readability, and even sometimes developers' preference. Our findings indicate that generating unit tests with ChatGPT could be very promising if the correctness of its generated tests could be further improved. Inspired by our findings above, we propose ChatTESTER, a novel ChatGPT-based unit test generation approach, which leverages ChatGPT itself to improve the quality of its generated tests. ChatTESTER incorporates an initial test generator and an iterative test refiner. Our evaluation demonstrates the effectiveness of ChatTESTER by generating 34.3% more compilable tests and 18.7% more tests with correct assertions than the default ChatGPT.

科研通智能强力驱动
Strongly Powered by AbleSci AI
科研通是完全免费的文献互助平台,具备全网最快的应助速度,最高的求助完成率。 对每一个文献求助,科研通都将尽心尽力,给求助人一个满意的交代。
实时播报
无奈萝完成签到,获得积分20
11秒前
20秒前
叶痕TNT完成签到 ,获得积分10
20秒前
gmc完成签到 ,获得积分10
23秒前
Hello应助萨尔莫斯采纳,获得10
23秒前
yingliusd完成签到,获得积分10
23秒前
酒酿汤圆发布了新的文献求助10
27秒前
雪花完成签到 ,获得积分10
30秒前
飞云完成签到 ,获得积分10
30秒前
小莫完成签到 ,获得积分10
33秒前
酒酿汤圆完成签到,获得积分10
46秒前
小静完成签到 ,获得积分10
48秒前
xuan发布了新的文献求助10
1分钟前
jasmine完成签到 ,获得积分10
1分钟前
迟大猫应助白华苍松采纳,获得10
1分钟前
huangzsdy完成签到,获得积分10
1分钟前
1分钟前
zz完成签到 ,获得积分10
1分钟前
xianyaoz完成签到 ,获得积分10
1分钟前
你要学好完成签到 ,获得积分10
1分钟前
天真的idiot完成签到 ,获得积分10
1分钟前
田様应助花花521采纳,获得10
1分钟前
安安完成签到 ,获得积分10
1分钟前
Cold-Drink-Shop完成签到,获得积分10
1分钟前
kingmp2完成签到 ,获得积分10
2分钟前
闪闪的谷梦完成签到 ,获得积分10
2分钟前
jia完成签到 ,获得积分10
2分钟前
大猪完成签到 ,获得积分10
2分钟前
坦率的从波完成签到 ,获得积分10
2分钟前
zyp应助张巨锋采纳,获得20
2分钟前
2分钟前
迟大猫应助白华苍松采纳,获得10
2分钟前
萨尔莫斯发布了新的文献求助10
2分钟前
danli完成签到 ,获得积分10
2分钟前
小白兔完成签到 ,获得积分10
2分钟前
科研通AI5应助萨尔莫斯采纳,获得10
2分钟前
2分钟前
王波完成签到 ,获得积分10
2分钟前
duxh123完成签到 ,获得积分10
2分钟前
Skywings完成签到,获得积分10
2分钟前
高分求助中
Continuum Thermodynamics and Material Modelling 3000
Production Logging: Theoretical and Interpretive Elements 2700
Kelsen’s Legacy: Legal Normativity, International Law and Democracy 1000
Interest Rate Modeling. Volume 3: Products and Risk Management 600
Interest Rate Modeling. Volume 2: Term Structure Models 600
Dynamika przenośników łańcuchowych 600
The King's Magnates: A Study of the Highest Officials of the Neo-Assyrian Empire 500
热门求助领域 (近24小时)
化学 材料科学 生物 医学 工程类 有机化学 生物化学 物理 纳米技术 计算机科学 内科学 化学工程 复合材料 基因 遗传学 物理化学 催化作用 量子力学 光电子学 冶金
热门帖子
关注 科研通微信公众号,转发送积分 3539114
求助须知:如何正确求助?哪些是违规求助? 3116731
关于积分的说明 9326595
捐赠科研通 2814659
什么是DOI,文献DOI怎么找? 1547002
邀请新用户注册赠送积分活动 720722
科研通“疑难数据库(出版商)”最低求助积分说明 712192