通过挖掘测试结构模式,加速扩散型大模型生成高质量单元测试。
DiffuTester: Accelerating Unit Test Generation for Diffusion LLMs via Mining Structural Pattern
- 基于抽象语法树识别测试用例的结构模式,动态优化生成过程。
- 在三个基准上实现显著加速,同时保持测试覆盖率不下降。
- 适用于多种扩散模型和编程语言,适合工程化自动测试场景。
扩散型大语言模型(dLLMs)支持并行生成,在单元测试生成(UTG)中具有高效大规模自动化测试的潜力。然而,其应用受限于效率与测试质量间的权衡:每步生成更多标记常导致测试质量急剧下降。为此,我们提出DiffuTester,一种专为dLLMs在UTG中设计的加速框架。其核心思路是:针对同一目标方法的单元测试常共享结构模式。DiffuTester采用基于结构模式的解码方法,通过抽象语法树动态识别测试间的共性模式,并针对性生成对应标记,实现加速而不牺牲输出质量。为支持全面评估,我们扩展了原始TestEval基准至三种编程语言。在三个基准上使用两种代表性模型的实验表明,DiffuTester在保持测试覆盖率的同时带来显著加速。此外,该方法在不同dLLMs和编程语言间具有良好泛化能力,为软件开发中的高效单元测试生成提供了实用且可扩展的解决方案。代码与数据已公开于https://github.com/TsinghuaISE/DiffuTester。
原文摘要 · Abstract (English)
Diffusion large language models (dLLMs) enable parallel generation and are promising for unit test generation (UTG), where efficient and large-scale automated testing is essential in software development. 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 DiffuTester, an acceleration framework specifically tailored for dLLMs in UTG. The motivation of DiffuTester is that unit tests targeting the same focal method often share structural patterns. DiffuTester employs a novel structural pattern based decoding approach, which dynamically identifies structural patterns across unit tests through their abstract syntax trees and additionally decodes the corresponding tokens, thereby achieving acceleration without compromising the quality of the output. To enable comprehensive evaluation, we extend the original TestEval benchmark to three programming languages. Extensive experiments on three benchmarks with two representative models show that DiffuTester delivers significant acceleration while preserving test coverage. Moreover, DiffuTester 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/TsinghuaISE/DiffuTester.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。