Software development relies heavily on extensive unit testing, which makes the efficiency of automated Unit Test Generation (UTG) particularly important. However, most existing LLMs generate test cases one token at a time in each forward pass, which leads to inefficient UTG. Recently, diffusion LLMs (dLLMs) have emerged, offering promising parallel generation capabilities and showing strong potential for efficient UTG. Despite this advantage, their application to UTG is still constrained by a clear trade-off between efficiency and test quality, since increasing the number of tokens generated in each step often causes a sharp decline in the quality of test cases. To overcome this limitation, we present DiffTester, an acceleration framework specifically tailored for dLLMs in UTG. The key idea of DiffTester is that unit tests targeting the same focal method often share repetitive structural patterns. By dynamically identifying these common patterns through abstract syntax tree analysis during generation, DiffTester adaptively increases the number of tokens produced at each step without compromising the quality of the output. To enable comprehensive evaluation, we extend the original TestEval benchmark, which was limited to Python, by introducing additional programming languages including Java and C++. Extensive experiments on three benchmarks with two representative models show that DiffTester delivers significant acceleration while preserving test coverage. Moreover, DiffTester generalizes well across different dLLMs and programming languages, providing a practical and scalable solution for efficient UTG in software development. Code and data are publicly available at https://github.com/wellbeingyang/DLM4UTG-open .


翻译:软件开发高度依赖广泛的单元测试,这使得自动化单元测试生成(UTG)的效率尤为重要。然而,现有大多数大语言模型(LLM)在每次前向传播中逐个令牌生成测试用例,导致UTG效率低下。近期出现的扩散大语言模型(dLLM)具备并行生成能力,为高效UTG展现出巨大潜力。尽管存在这一优势,dLLM在UTG中的应用仍受限于效率与测试质量间的明显权衡——增加单步生成令牌数常导致测试用例质量急剧下降。为突破此限制,本文提出DiffTester,专为dLLM在UTG中设计的加速框架。其核心思想在于:针对同一焦点方法的单元测试常共享重复的结构模式。DiffTester通过生成过程中的抽象语法树分析动态识别这些共性模式,从而在保证输出质量的前提下自适应增加单步生成令牌数。为进行全面评估,我们在原有仅支持Python的TestEval基准测试基础上,扩展了包含Java与C++的多编程语言测试集。基于两种代表性模型在三个基准测试上的大量实验表明,DiffTester在保持测试覆盖度的同时实现了显著加速。此外,DiffTester在不同dLLM与编程语言间均表现出良好泛化能力,为软件开发中的高效UTG提供了实用且可扩展的解决方案。代码与数据已公开于https://github.com/wellbeingyang/DLM4UTG-open。

0
下载
关闭预览

相关内容

PlanGenLLMs:大型语言模型规划能力的最新综述
专知会员服务
32+阅读 · 5月18日
Python图像处理,366页pdf,Image Operators Image Processing in Python
论文浅尝 | GEOM-GCN: Geometric Graph Convolutional Networks
开放知识图谱
14+阅读 · 2020年4月8日
国家自然科学基金
17+阅读 · 2017年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
3+阅读 · 2015年12月31日
国家自然科学基金
4+阅读 · 2015年12月31日
国家自然科学基金
46+阅读 · 2015年12月31日
VIP会员
相关基金
国家自然科学基金
17+阅读 · 2017年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
3+阅读 · 2015年12月31日
国家自然科学基金
4+阅读 · 2015年12月31日
国家自然科学基金
46+阅读 · 2015年12月31日
Top
微信扫码咨询专知VIP会员