Code-Aware Prompting: A Study of Coverage-Guided Test Generation in Regression Setting using LLM
Gabriel Ryan, Siddhartha Jain, Mingyue Shang, Shiqi Wang, Xiaofei Ma, Murali Krishna Ramanathan, Baishakhi Ray
摘要
Testing plays a pivotal role in ensuring software quality, yet conventional Search Based Software Testing (SBST) methods often struggle with complex software units, achieving suboptimal test coverage. Recent work using large language models (LLMs) for test generation have focused on improving generation quality through optimizing the test generation context and correcting errors in model outputs, but use fixed prompting strategies that prompt the model to generate tests without additional guidance. As a result LLM-generated testsuites still suffer from low coverage. In this paper, we present SymPrompt, a code-aware prompting strategy for LLMs in test generation. SymPrompt’s approach is based on recent work that demonstrates LLMs can solve more complex logical problems when prompted to reason about the problem in a multi-step fashion. We apply this methodology to test generation by deconstructing the testsuite generation process into a multi-stage sequence, each of which is driven by a specific prompt aligned with the execution paths of the method under test, and exposing relevant type and dependency focal context to the model. Our approach enables pretrained LLMs to generate more complete test cases without any additional training. We implement SymPrompt using the TreeSitter parsing framework and evaluate on a benchmark challenging methods from open source Python projects. SymPrompt enhances correct test generations by a factor of 5 and bolsters relative coverage by 26% for CodeGen2. Notably, when applied to GPT-4, SymPrompt improves coverage by over 2× compared to baseline prompting strategies.
问 Lune
几分钟读透这篇 Paper,不用再花一下午。
Lune 能读完全文,也能读引用它的顶会 Paper,讲清它的结论、证据和局限,每一点都注明出自哪篇 Paper。不用硬啃,也不靠猜。
已有 40 篇顶会 Paper 引用了它。别等审稿人问起,先弄清它们发现了什么。
脉络
- CodaMosa: Escaping Coverage Plateaus in Test Generation with Pre-trained Large Language Models 引用了 TOGA: A Neural Method for Test Oracle Generation
- Agentic Concolic Execution 引用了 You Name It, I Run It: An LLM Agent to Execute Tests of Arbitrary Projects
- Agentic Concolic Execution 引用了 Chain-of-Thought Prompting Elicits Reasoning in Large Language Models
- Tree of Thoughts: Deliberate Problem Solving with Large Language Models 引用了 Chain-of-Thought Prompting Elicits Reasoning in Large Language Models
- RepairAgent: An Autonomous, LLM-Based Agent for Program Repair 引用了 CodaMosa: Escaping Coverage Plateaus in Test Generation with Pre-trained Large Language Models
- RepairAgent: An Autonomous, LLM-Based Agent for Program Repair 引用了 Chain-of-Thought Prompting Elicits Reasoning in Large Language Models
- You Name It, I Run It: An LLM Agent to Execute Tests of Arbitrary Projects 引用了 CodaMosa: Escaping Coverage Plateaus in Test Generation with Pre-trained Large Language Models
- You Name It, I Run It: An LLM Agent to Execute Tests of Arbitrary Projects 引用了 RepairAgent: An Autonomous, LLM-Based Agent for Program Repair
- You Name It, I Run It: An LLM Agent to Execute Tests of Arbitrary Projects 引用了 Chain-of-Thought Prompting Elicits Reasoning in Large Language Models
- HITS: High-coverage LLM-based Unit Test Generation via Method Slicing 引用了 CodaMosa: Escaping Coverage Plateaus in Test Generation with Pre-trained Large Language Models
引用它的顶会 Paper40
- RepairAgent: An Autonomous, LLM-Based Agent for Program RepairIslem Bouzenia, Premkumar T. Devanbu, Michael PradelICSE 2025 · 54 次引用
- HITS: High-coverage LLM-based Unit Test Generation via Method SlicingZejun Wang, Kaibo Liu, Ge Li, Zhi JinASE 2024 · 29 次引用
- LLM-Powered Test Case Generation for Detecting Bugs in Plausible ProgramsKaibo Liu, Zhenpeng Chen, Yiyang Liu, Jie M. Zhang 等ACL 2025 · 20 次引用
- Agentic Concolic ExecutionZhengxiong Luo, Huan Zhao, Dylan Wolff, Cristian Cadar 等S&P 2026 · 17 次引用
- You Name It, I Run It: An LLM Agent to Execute Tests of Arbitrary ProjectsIslem Bouzenia, Michael PradelISSTA 2025 · 17 次引用
它引用的 Paper4
- Chain-of-Thought Prompting Elicits Reasoning in Large Language ModelsJason Wei, Xuezhi Wang, Dale Schuurmans, Maarten Bosma 等NeurIPS 2022 · 22,562 次引用
- Tree of Thoughts: Deliberate Problem Solving with Large Language ModelsShunyu Yao, Dian Yu, Jeffrey Zhao, Izhak Shafran 等NeurIPS 2023 · 5,068 次引用
- CodaMosa: Escaping Coverage Plateaus in Test Generation with Pre-trained Large Language ModelsCaroline Lemieux, Jeevana Priya Inala, Shuvendu K. Lahiri, Siddhartha SenICSE 2023 · 221 次引用
- TOGA: A Neural Method for Test Oracle GenerationElizabeth Dinella, Gabriel Ryan, Todd Mytkowicz, Shuvendu K. LahiriICSE 2022 · 92 次引用
相关 Paper
- On the Evaluation of Large Language Models in Unit Test GenerationLin Yang, Chen Yang, Shutao Gao, Weijing Wang 等ASE 2024 · 42 次引用
- CAT-LM Training Language Models on Aligned Code And TestsNikitha Rao, Kush Jain, Uri Alon, Claire Le Goues 等ASE 2023 · 37 次引用
- CoverUp: Effective High Coverage Test Generation for PythonJuan Altmayer Pizzorno, Emery D. BergerFSE 2025 · 13 次引用
- MoT: Modularization-of-Thought Prompting for Effective Code GenerationRuwei Pan, Hongyu ZhangISSTA 2026
- Execution-guided within-prompt search for programming-by-exampleGust Verbruggen, Ashish Tiwari, Mukul Singh, Vu Le 等ICLR 2025
