arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2603.23443cs.SEcs.AI
收藏

评估基于大语言模型的测试生成在软件演化中的表现

Evaluating LLM-Based Test Generation Under Software Evolution

Carnegie Mellon University(卡内基梅隆大学)

Sabaat Haroon, Mohammad Taha Khan, Muhammad Ali Gulzar

AI总结:

研究评估了基于大语言模型的测试生成在软件演化中的性能,发现其在代码变化时表现下降,测试覆盖和回归检测能力不足。

摘要:

大型语言模型(LLMs)越来越多地用于自动化单元测试生成。然而,尚不清楚这些测试是否反映了对程序行为的真实推理,还是仅仅复制了训练期间学习到的表面模式。如果后者占主导地位,LLM生成的测试可能会出现覆盖减少、遗漏回归和未检测故障等弱点。理解LLM如何生成测试以及这些测试如何响应代码演化是必要的。我们呈现了一项大规模的经验研究,分析了在程序变化下基于LLM的测试生成。使用自动化突变驱动框架,我们分析了生成的测试如何响应语义改变(SAC)和语义保持(SPC)的变化,涵盖了八个LLM和22,374个程序变体。LLMs在完全通过的原始程序测试套件中达到了79%的行覆盖和76%的分支覆盖。然而,随着程序的演化,性能会下降。在SAC下,新生成的测试通过率降至66%,分支覆盖降至60%。超过99%的失败SAC测试在原始程序执行修改区域时通过,表明与原始行为的残余一致性,而非适应更新的语义。在SPC下,尽管功能未变,性能也下降:通过率降至79%,分支覆盖降至69%。虽然SPC编辑保持语义,但它们通常引入更大的语法变化,导致生成测试套件的不稳定性。模型生成更多新测试并丢弃许多基准测试,表明对词汇变化的敏感性,而非真正的语义影响。总体而言,我们的结果表明,当前基于LLM的测试生成严重依赖于表面线索,并在程序演化时难以维持回归意识。

英文摘要:

Large Language Models (LLMs) are increasingly used for automated unit test generation. However, it remains unclear whether these tests reflect genuine reasoning about program behavior or simply reproduce superficial patterns learned during training. If the latter dominates, LLM-generated tests may exhibit weaknesses such as reduced coverage, missed regressions, and undetected faults. Understanding how LLMs generate tests and how those tests respond to code evolution is therefore essential. We present a large-scale empirical study of LLM-based test generation under program changes. Using an automated mutation-driven framework, we analyze how generated tests react to semantic-altering changes (SAC) and semantic-preserving changes (SPC) across eight LLMs and 22,374 program variants. LLMs achieve strong baseline results, reaching 79% line coverage and 76% branch coverage with fully passing test suites on the original programs. However, performance degrades as programs evolve. Under SACs, the pass rate of newly generated tests drops to 66%, and branch coverage declines to 60%. More than 99% of failing SAC tests pass on the original program while executing the modified region, indicating residual alignment with the original behavior rather than adaptation to updated semantics. Performance also declines under SPCs despite unchanged functionality: pass rates fall to 79% and branch coverage to 69%. Although SPC edits preserve semantics, they often introduce larger syntactic changes, leading to instability in generated test suites. Models generate more new tests while discarding many baseline tests, suggesting sensitivity to lexical changes rather than true semantic impact. Overall, our results indicate that current LLM-based test generation relies heavily on surface-level cues and struggles to maintain regression awareness as programs evolve.

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

↑