A Path-Guided and Iterative Optimization Strategy for Unit Test Case Generation with 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.

Authors

Institutions

Publication Details

Journal
International Journal of Software Engineering and Knowledge Engineering
Published
2026-09-10
DOI
https://doi.org/10.1142/s021819402650083x
Primary Topic
Software Testing and Debugging Techniques
Type
article
Field-Weighted Citation Impact
0.00
Controls
|||
ALL TIME
JAN
FEB
MAR
APR
MAY
JUN
JUL
AUG
SEP
OCT
article

A Path-Guided and Iterative Optimization Strategy for Unit Test Case Generation with Large Language Models

Yukun Dong, Xiaoshan Liu, Shuo Wang, Mingcheng Chen et al.
International Journal of Software Engineering and Knowledge Engineering
Software Testing and Debugging Techniques
article

A Path-Guided and Iterative Optimization Strategy for Unit Test Case Generation with Large Language Models

Yukun Dong, Xiaoshan Liu, Shuo Wang, Mingcheng Chen, Xinran Meng, Shuai Liu, Zhikun Lv
article en

Abstract

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.

International Journal of Software Engineering and Knowledge Engineering
Twitter (United States) (US)
Openalex Percentile: Top 5%
Software Testing and Debugging Techniques
AI Navigator

Ask Laika to Summarize, Analyze, and Connect papers live on the map.

Summarize Papers & Methodologies

Extract key findings, datasets, and comparative methods across publications.

Benchmark Rankings & Visual Analytics

Rank top research institutions, authors, funders, topics, and journals by Field-Weighted Citation Impact (FWCI) and paper volume with instant charts.

Connect Distant Disciplines

Bridge topological clusters on the map to find hidden collaborative intersections.