Answers are grounded in this paper and cite their sources.
Experimental evaluation demonstrates up to 97% code coverage in automated unit testing, suggesting control flow graphs effectively guide large language models.
The rise of Large Language Models (LLMs) has significantly impacted software engineering, particularly in automating unit test case generation. However, current methods often fall short of achieving comprehensive test coverage, especially for complex code structures and critical execution paths. This paper presents a novel Path-Guided and Iterative Optimization Strategy for unit test case generation. By integrating LLMs with Control Flow Graph (CFG) analysis and iterative refinement, the strategy efficiently identifies untested execution paths, improves test coverage, and enhances test case accuracy. The proposed strategy employs a Path-Guided method, utilizing CFG analysis to explore reachable basic paths. It integrates Path-Guided contextual information with LLMs and applies C-P-R (Context-Prompt-Response) templated guidance to generate high-quality unit test cases. A Dual Validation mechanism ensures the assertion accuracy and reliability of the initial test cases, followed by Iterative Optimization, which progressively refines test cases to address coverage gaps. The experimental results demonstrate that the proposed strategy significantly enhances the quality of generated test cases. Using the Path-Guided and Iterative Optimization strategy, the method achieves a maximum of 97% line coverage and 94% branch coverage while also improving the precision of test cases.
No takes yet. Share an insight, caveat, or question.
Dong et al. (2026) studied this question.
Synapse has enriched 10 related papers. Consider them for comparative context: