计算机科学
图形
算法
控制流程图
编码(集合论)
控制系统
关系(数据库)
控制(管理)
流量(数学)
单位(环理论)
控制单元
作者
Xinran Luo,Cheng Liu,Mengchen Zhao,Zhibin Wu,Tao Lu,Junying Chen
出处
期刊:
[Institute of Electrical and Electronics Engineers]
日期:2026-06-01
卷期号:: 1-8
被引量:1
标识
DOI:10.1109/ijcnn69854.2026.11729616
摘要
Unit testing is a critical yet labor intensive phase in software development. Although large language models (LLMs) have shown promise in unit test code generation, existing LLM-based methods often suffer from limited code understanding, high error rate, and low test coverage. We propose an approach that leverages control flow graphs (CFGs) to improve test quality and coverage. Our method comprises three phases. In the data pre-processing phase, we extract focal methods and dependencies from Java projects and construct CFGs from the abstract syntax tree, which allows LLMs to better focus on the core logic. In the code generation phase, we use LLM to decompose each focal method into CFG-based code slices and generate a coherent unit test code for each slice. In the post-processing optimization phase, we apply a two-stage repair strategy for failing tests to ensure greater test executability, combining template-based repair with LLM-based repair. To further boost coverage, we analyze uncovered control paths via the CFG and guide the LLM to optimize the unit test code test cases accordingly. Experimental results show that our approach significantly outperforms baselines in terms of test execution pass rate and code coverage, with ablation studies highlighting strong inter-module synergy. All experimental data and source code are available at https://github.com/EllaDrCarrot/LUGC.
科研通智能强力驱动
Strongly Powered by AbleSci AI