arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2402.03396cs.SEcs.AIcs.CLcs.CRcs.LG
收藏

UniTSyn:一个能够增强大型语言模型程序测试能力的大规模数据集

UniTSyn: A Large-Scale Dataset Capable of Enhancing the Prowess of Large Language Models for Program Testing

UC Davis(加州大学戴维斯分校);Tencent Security Big Data Lab(腾讯安全大数据实验室)

Yifeng He, Jiabo Huang, Yuyang Rong, Yiwen Guo, Ethan Wang, Hao Chen

AI总结:

本文提出大规模数据集UniTSyn,通过语言服务器协议收集270万焦点-测试对,增强大型语言模型生成单元测试的准确性与覆盖率。

摘要:

大型语言模型(LLMs)在生成高质量代码方面的卓越能力已引起软件测试社区的日益关注。然而,现有的代码LLMs在生成准确且完整的测试方面往往表现不佳,因为它们的训练数据是在未区分测试用途代码与其他代码的情况下收集的代码片段。在本文中,我们提出了一个大规模数据集UniTSyn,它能够增强LLMs在单元测试合成方面的能力。将测试与被测函数关联起来,对于LLMs推断预期行为和待验证的逻辑路径至关重要。通过利用语言服务器协议(Language Server Protocol),UniTSyn实现了无需逐项目执行设置或逐语言启发式方法(这些方法往往脆弱且难以扩展)即可收集焦点-测试对(focal-test pairs)这一具有挑战性的目标。该数据集包含五种主流编程语言的270万个焦点-测试对,使其能够用于增强LLMs的测试生成能力。UniTSyn的详细信息见表1。我们的实验表明,通过基于UniTSyn构建自回归模型,我们可以在学习和理解单元测试表示方面获得显著收益,从而在所有评估的编程语言中提高生成准确性和代码覆盖率。代码和数据将公开提供。

英文摘要:

The remarkable capability of large language models (LLMs) in generating high-quality code has drawn increasing attention in the software testing community. However, existing code LLMs often demonstrate unsatisfactory capabilities in generating accurate and complete tests since they were trained on code snippets collected without differentiating between code for testing purposes and other code. In this paper, we present a large-scale dataset UniTSyn, which is capable of enhancing the prowess of LLMs for Unit Test Synthesis. Associating tests with the tested functions is crucial for LLMs to infer the expected behavior and the logic paths to be verified. By leveraging Language Server Protocol, UniTSyn achieves the challenging goal of collecting focal-test pairs without per-project execution setups or per-language heuristics that tend to be fragile and difficult to scale. It contains 2.7 million focal-test pairs across five mainstream programming languages, making it possible to be utilized for enhancing the test generation ability of LLMs. The details of UniTSyn can be found in Table 1. Our experiments demonstrate that, by building an autoregressive model based on UniTSyn, we can achieve significant benefits in learning and understanding unit test representations, resulting in improved generation accuracy and code coverage across all evaluated programming languages. Code and data will be publicly available.

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

↑