42digest首页
断言-感知测试代码与大型语言模型的总结

Assertion-Aware Test Code Summarization with Large Language Models

Anamul Haque Mollah, Ahmed Aljohani, Hyunsook Do

arXiv
2025年11月9日

单元测试通常缺乏传达测试意图的简明摘要,特别是在自动生成或记录不佳的代码库中。 大型语言模型(LLM)提供了一个有前途的解决方案,但它们的有效性在很大程度上取决于它们的提示方式。 与通用代码总结不同,测试代码总结带来了不同的挑战,因为测试方法通过断言而不是实现功能来验证预期行为。 本文提出了91个现实世界的Java测试用例与开发人员编写的摘要配对的新基准,并进行了一个受控消融研究,以研究测试代码相关组件(如正在测试的方法(MUT),断言消息和断言语义 - 如何影响LLM生成的测试摘要的性能。 我们使用 n-gram 指标(BLEU、ROUGE-L、METEOR)、语义相似性(BERTScore)和基于 LLM 的评估,在七个提示配置中评估四个代码 LLM(Codex、Codestral、DeepSeek 和 Qwen-Coder)。 结果表明,使用断言语义的提示在全MUT上下文(4.45 vs.45 vs.)上将摘要质量提高了平均0.10点(2.3%)。 4.35,同时需要更少的输入令牌。 Codex和Qwen-Coder实现了与人类编写的摘要的最高一致性,而DeepSeek尽管词汇重叠很高,但表现不佳。 复制包可公开查阅https://doi.org/10。 5281/zenodo.17067550

Unit tests often lack concise summaries that convey test intent, especially in auto-generated or poorly documented codebases. Large Language Models (LLMs) offer a promising solution, but their effectiveness depends heavily on how they are prompted. Unlike generic code summarization, test-code summarization poses distinct challenges because test methods validate expected behavior through assertions rather than implementing functionality. This paper presents a new benchmark of 91 real-world Java t...