arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2602.00409cs.SE
收藏

编码代理是否生成过度的模拟测试?一项实证研究

Are Coding Agents Generating Over-Mocked Tests? An Empirical Study

UFMG(米纳斯吉拉斯联邦大学);Univ. Bordeaux, CNRS, Bordeaux INP, LaBRI(波尔多大学、法国国家科学研究中心、波尔多国立高等电子与计算机学院、拉布里实验室)

Andre Hora, Romain Robbes

AI总结:

本文研究了编码代理生成测试中模拟的使用情况,发现代理更倾向于修改测试并添加模拟,同时指出模拟测试可能更容易自动生成但验证效果较弱。

摘要:

编码代理在软件开发中近年来受到了显著采用。与传统的基于LLM的代码补全工具不同,编码代理具有自主性(例如调用外部工具)并在软件仓库中留下可见的痕迹,例如编写提交。在它们的任务中,编码代理可能自主地生成软件测试;然而,这些测试的质量仍然不确定。特别是过度使用模拟会使测试更难理解和维护。本文提出了第一项研究,旨在调查真实世界软件系统中代理生成的测试中的模拟存在情况。我们分析了2025年在2168个TypeScript、JavaScript和Python仓库中超过120万个提交,其中包括48563个由编码代理生成的提交、169361个修改测试的提交以及44900个添加模拟到测试的提交。总体而言,我们发现编码代理比非编码代理更可能修改测试并添加模拟到测试中。我们发现(1)60%包含代理活动的仓库也包含代理测试活动;(2)23%由编码代理生成的提交修改测试文件,与非代理生成的13%相比;(3)68%包含代理测试活动的仓库也包含代理模拟活动;(4)36%由编码代理生成的提交添加模拟到测试中,与非代理生成的26%相比;(5)近期创建的仓库中包含更多由代理生成的测试和模拟提交。最后,我们通过讨论对开发者和研究人员的影响来总结。我们指出,带有模拟的测试可能更容易自动生成(但不如验证真实交互有效),并需要在代理配置文件中包含有关模拟实践的指导。

英文摘要:

Coding agents have received significant adoption in software development recently. Unlike traditional LLM-based code completion tools, coding agents work with autonomy (e.g., invoking external tools) and leave visible traces in software repositories, such as authoring commits. Among their tasks, coding agents may autonomously generate software tests; however, the quality of these tests remains uncertain. In particular, excessive use of mocking can make tests harder to understand and maintain. This paper presents the first study to investigate the presence of mocks in agent-generated tests of real-world software systems. We analyzed over 1.2 million commits made in 2025 in 2,168 TypeScript, JavaScript, and Python repositories, including 48,563 commits by coding agents, 169,361 commits that modify tests, and 44,900 commits that add mocks to tests. Overall, we find that coding agents are more likely to modify tests and to add mocks to tests than non-coding agents. We detect that (1) 60% of the repositories with agent activity also contain agent test activity; (2) 23% of commits made by coding agents add/change test files, compared with 13% by non-agents; (3) 68% of the repositories with agent test activity also contain agent mock activity; (4) 36% of commits made by coding agents add mocks to tests, compared with 26% by non-agents; and (5) repositories created recently contain a higher proportion of test and mock commits made by agents. Finally, we conclude by discussing implications for developers and researchers. We call attention to the fact that tests with mocks may be potentially easier to generate automatically (but less effective at validating real interactions), and the need to include guidance on mocking practices in agent configuration files.

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

↑