PALM: Synergizing Program Analysis and LLMs to Enhance Rust Unit Test Coverage

Fuente: arXiv
Saved in:
Bibliographic Details
Main Authors: Chu, Bei, Feng, Yang, Liu, Kui, Shi, Hange, Nan, Zifan, Guo, Zhaoqiang, Xu, Baowen
Format: Preprint
Published: 2025
Subjects:
Online Access:
Tags: Add Tag
No Tags, Be the first to tag this record!
_version_ 1866914063621029888
author Chu, Bei
Feng, Yang
Liu, Kui
Shi, Hange
Nan, Zifan
Guo, Zhaoqiang
Xu, Baowen
author_facet Chu, Bei
Feng, Yang
Liu, Kui
Shi, Hange
Nan, Zifan
Guo, Zhaoqiang
Xu, Baowen
contents Unit testing is essential for ensuring software reliability and correctness. Classic Search-Based Software Testing (SBST) methods and concolic execution-based approaches for generating unit tests often fail to achieve high coverage due to difficulties in handling complex program units, such as branching conditions and external dependencies. Recent work has increasingly utilized large language models (LLMs) to generate test cases, improving the quality of test generation by providing better context and correcting errors in the model's output. However, these methods rely on fixed prompts, resulting in relatively low compilation success rates and coverage. This paper presents PALM, an approach that leverages large language models (LLMs) to enhance the generation of high-coverage unit tests. PALM performs program analysis to identify branching conditions within functions, which are then combined into path constraints. These constraints and relevant contextual information are used to construct prompts that guide the LLMs in generating unit tests. We implement the approach and evaluate it in 15 open-source Rust crates. Experimental results show that within just two or three hours, PALM can significantly improve test coverage compared to classic methods, with increases in overall project coverage exceeding 50% in some instances and its generated tests achieving an average coverage of 72.30%, comparable to human effort (70.94%), highlighting the potential of LLMs in automated test generation. We submitted 91 PALM-generated unit tests targeting new code. Of these submissions, 80 were accepted, 5 were rejected, and 6 remain pending review. The results demonstrate the effectiveness of integrating program analysis with AI and open new avenues for future research in automated software testing.
format Preprint
id arxiv_https___arxiv_org_abs_2506_09002
institution arXiv
publishDate 2025
record_format arxiv
spellingShingle PALM: Synergizing Program Analysis and LLMs to Enhance Rust Unit Test Coverage
Chu, Bei
Feng, Yang
Liu, Kui
Shi, Hange
Nan, Zifan
Guo, Zhaoqiang
Xu, Baowen
Software Engineering
Unit testing is essential for ensuring software reliability and correctness. Classic Search-Based Software Testing (SBST) methods and concolic execution-based approaches for generating unit tests often fail to achieve high coverage due to difficulties in handling complex program units, such as branching conditions and external dependencies. Recent work has increasingly utilized large language models (LLMs) to generate test cases, improving the quality of test generation by providing better context and correcting errors in the model's output. However, these methods rely on fixed prompts, resulting in relatively low compilation success rates and coverage. This paper presents PALM, an approach that leverages large language models (LLMs) to enhance the generation of high-coverage unit tests. PALM performs program analysis to identify branching conditions within functions, which are then combined into path constraints. These constraints and relevant contextual information are used to construct prompts that guide the LLMs in generating unit tests. We implement the approach and evaluate it in 15 open-source Rust crates. Experimental results show that within just two or three hours, PALM can significantly improve test coverage compared to classic methods, with increases in overall project coverage exceeding 50% in some instances and its generated tests achieving an average coverage of 72.30%, comparable to human effort (70.94%), highlighting the potential of LLMs in automated test generation. We submitted 91 PALM-generated unit tests targeting new code. Of these submissions, 80 were accepted, 5 were rejected, and 6 remain pending review. The results demonstrate the effectiveness of integrating program analysis with AI and open new avenues for future research in automated software testing.
title PALM: Synergizing Program Analysis and LLMs to Enhance Rust Unit Test Coverage
topic Software Engineering
url https://arxiv.org/abs/2506.09002