arXiv:2604.17715cs.SEcs.LG2026-04ACL

让大模型理解代码结构,精准生成能发现漏洞的测试用例。

Program Structure-aware Language Models: Targeted Software Testing beyond Textual Semantics

论文配图:Program Structure-aware Language Models: Targeted Software Testing beyond Textual Semantics
图 1 · 摘自论文原文
  • 结合代码图谱与语义,用图神经网络引导大模型生成测试用例。
  • 在真实项目中将分支命中率从27.4%提升至50.2%,显著提高漏洞发现能力。
  • 适合安全测试、自动化测试团队,尤其关注高风险代码路径的场景。

当前基于大语言模型的测试用例生成方法虽通过提示工程提升了分支覆盖率,但仍缺乏有效机制引导模型聚焦高风险执行路径,限制了其对细微缺陷和安全漏洞的发现能力。本文提出GLMTest,首个面向程序结构的大型语言模型框架,通过图神经网络与语言模型协同,融合代码属性图与代码语义,实现对特定执行分支的可控生成。该结构化引导机制显著提升了测试用例的目标性与有效性。在真实项目上的实验表明,基于Qwen2.5-Coder-7B-Instruct模型的GLMTest,在TestGenEval基准上将分支准确率从27.4%提升至50.2%,优于Claude-Sonnet-4.5与GPT-4o-mini等先进模型。

原文摘要 · Abstract (English)

Recent advances in large language models for test case generation have improved branch coverage via prompt-engineered mutations. However, they still lack principled mechanisms for steering models toward specific high-risk execution branches, limiting their effectiveness for discovering subtle bugs and security vulnerabilities. We propose GLMTest, the first program structure-aware LLM framework for targeted test case generation that seamlessly integrates code property graphs and code semantics using a graph neural network and a language model to condition test case generation on execution branches. This structured conditioning enables controllable and branch-targeted test case generation, thereby potentially enhancing bug and security risk discovery. Experiments on real-world projects show that GLMTest built on a Qwen2.5-Coder-7B-Instruct model improves branch accuracy from 27.4% to 50.2% on TestGenEval benchmark compared with state-of-the-art LLMs, i.e., Claude-Sonnet-4.5 and GPT-4o-mini.

代码生成测试用例安全检测图神经网络

Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。