Journals
  Publication Years
  Keywords
Search within results Open Search
Please wait a minute...
For Selected: Toggle Thumbnails
Unit test generation method based on path constraint sharding driven large language model
Xiaolong XU, Junfeng WANG, Peng WU, Xiansheng CAO
Journal of Computer Applications    2026, 46 (10): 3298-3306.   DOI: 10.11772/j.issn.1001-9081.2025091085
Abstract (194)   HTML (0)    PDF (2297KB)(47)       Save

Automated unit test generation is the key to modern software development to improve development efficiency and ensure software quality. Large Language Models (LLMs) are applied to automated test case generation because of their good code understanding ability. However, when dealing with complex functions, it is difficult for LLMs to cover deep branch paths. Therefore, PyULLM method was proposed, which combined path constraint sharding with LLM generation ability to solve the above problems. Specifically, all the path constraints were collected systematically by preorder traversal of the abstract syntax tree. On this basis, a fine-grained relationship between code lines and path constraints was established. According to the obtained relationship, intelligent partitioning of path constraint set was performed. LLM was able to focus on specific path constraints by this partitioning mechanism, which improved the coverage of generated unit test cases in complex scenarios significantly. Experimental results show that compared with the SOTA(State Of The Arts) tool Pynguin, PyULLM method improves the Line Coverage ratio (LC) by 24.16 percentage points and the Branch Coverage ratio (BC) by 26.61 percentage points; compared with the current SOTA method CodaMosa, PyULLM method has the LC improved by 19.06 percentage points, and the BC increased by 21.72 percentage points. It can be seen that PyULLM method can generate unit test cases for complex functions effectively.

Table and Figures | Reference | Related Articles | Metrics