arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2403.16218cs.SEcs.AIcs.LGcs.PL
收藏

CoverUp:面向 Python 的高效高覆盖率测试生成

CoverUp: Effective High Coverage Test Generation for Python

University of Massachusetts Amherst(马萨诸塞大学阿默斯特分校)

Juan Altmayer Pizzorno, Emery D. Berger

AI总结:

CoverUp 通过结合覆盖率分析、代码上下文和反馈迭代引导 LLM 生成 Python 回归测试,在基准上显著超越 CodaMosa 和 MuTAP,实现更高的行与分支覆盖率。

摘要:

测试是软件开发的重要组成部分。测试生成工具试图自动化原本劳动密集型的测试创建任务,但生成高覆盖率测试仍然具有挑战性。本文提出了 CoverUp,一种驱动高覆盖率 Python 回归测试生成的新方法。CoverUp 在提示中结合覆盖率分析、代码上下文和反馈,迭代引导大语言模型(LLM)生成能够提升行覆盖率和分支覆盖率的测试。我们在一个由开源 Python 项目衍生的具有挑战性的代码基准上评估了 CoverUp 原型实现,并表明 CoverUp 显著优于当前最先进的方法。与混合搜索/LLM 测试生成器 CodaMosa 相比,CoverUp 实现了每个模块 80% 的行+分支覆盖率中位数(对比 47%)。与基于变异和 LLM 的测试生成器 MuTAP 相比,CoverUp 实现了 89% 的整体行+分支覆盖率(对比 77%)。我们还证明 CoverUp 的性能不仅源于所使用的 LLM,还源于其各组件的综合有效性。

英文摘要:

Testing is an essential part of software development. Test generation tools attempt to automate the otherwise labor-intensive task of test creation, but generating high-coverage tests remains challenging. This paper proposes CoverUp, a novel approach to driving the generation of high-coverage Python regression tests. CoverUp combines coverage analysis, code context, and feedback in prompts that iteratively guide the LLM to generate tests that improve line and branch coverage. We evaluate our prototype CoverUp implementation across a benchmark of challenging code derived from open-source Python projects and show that CoverUp substantially improves on the state of the art. Compared to CodaMosa, a hybrid search/LLM-based test generator, CoverUp achieves a per-module median line+branch coverage of 80% (vs. 47%). Compared to MuTAP, a mutation- and LLM-based test generator, CoverUp achieves an overall line+branch coverage of 89% (vs. 77%). We also demonstrate that CoverUp's performance stems not only from the LLM used but from the combined effectiveness of its components.

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

↑