Chrome Extension
WeChat Mini Program
Use on ChatGLM

Code-Aware Prompting: A Study of Coverage Guided Test Generation in Regression Setting Using LLM

Proc ACM Softw Eng(2024)

Columbia University | AWS AI Labs

Cited 1|Views94
Abstract
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 2x compared to baseline prompting strategies.
More
Translated text
Key words
Large Language Models,Test Generation
PDF
Bibtex
AI Read Science
Video&Figures
Must-Reading Tree
Example
Generate MRT to find the research sequence of this paper
Data Disclaimer
The page data are from open Internet sources, cooperative publishers and automatic analysis results through AI technology. We do not make any commitments and guarantees for the validity, accuracy, correctness, reliability, completeness and timeliness of the page data. If you have any questions, please contact us by email: report@aminer.cn
Chat Paper

要点】:本文提出了一种名为SymPrompt的代码感知提示策略,通过引导大型语言模型(LLM)分阶段生成测试用例,显著提高了测试覆盖率。

方法】:SymPrompt将测试用例生成过程分解为多阶段序列,每个阶段由与被测试方法的执行路径对齐的特定提示驱动,并暴露相关的类型和依赖焦点上下文。

实验】:使用TreeSitter解析框架实现SymPrompt,并在来自开源Python项目的基准上评估,结果显示SymPrompt将正确测试用例的生成提高了5倍,相对覆盖率提高了26%,与基线提示策略相比,符号路径提示将覆盖率提高了超过2倍。