一句话:结合程序分析提取路径约束与LLM生成Rust高覆盖率单元测试,并在开源crate上验证及提交补丁。
单元测试对软件可靠性至关重要,但传统SBST与concolic执行在处理复杂分支条件和外部依赖时覆盖率有限,现有LLM方法又依赖固定提示,编译成功率与覆盖率较低。PALM通过程序分析识别函数内部分支条件并组合为路径约束,再结合上下文构造提示,引导LLM生成单元测试。作者在15个开源Rust crate上评估,发现仅需两三小时即可显著提升项目覆盖率,部分项目整体覆盖率提升超过50%,生成测试平均覆盖率达72.30%,接近人工水平70.94%。提交的91个针对新代码的测试中80个被接受、5个被拒、6个待审,表明程序分析与AI结合能有效改进自动化测试生成。
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.
DOI 原文 ·
@inproceedings{paperbot9537,
title = {PALM: Synergizing Program Analysis and LLMs to Enhance Rust Unit Test Coverage},
author = {Bei Chu and Yang Feng and Kui Liu and Hange Shi and Zifan Nan and Zhaoqiang Guo and Baowen Xu},
booktitle = {ASE},
year = {2025},
doi = {10.1109/ase63991.2025.00223}
}