paperbot · PL 论文追踪

全部论文 待读 收藏

RustGTC: Constraint-Guided Test Generation for Rust APIs via Comment Analysis and Code Context

RustGTC:通过注释分析与代码上下文实现约束引导的 Rust API 测试生成
ASE Proceedings of the 41st IEEE/ACM International Conference on Automated Software Engineering2026引用 0 inbox
Yichi Zhang, Jinhao Huang, Yang Feng
crossref: 2026-10-09

AI 速览

一句话:从 API 注释中抽取参数约束来引导 LLM 生成并修复 Rust API 测试,在 12 个 crate 上发现 41 个缺陷。

为 Rust API 手工编写测试成本高且易出错,Rust 的高级语言特性与复杂 trait 系统更加剧了这一困难。尽管大语言模型(LLM)已被用于自动化测试生成,但现有方法往往未能充分利用 API 注释中记录的输入要求。本文提出 RustGTC:它从注释中抽取文档化的参数约束,结合代码上下文围绕边界情况构造测试,并对生成的测试进行修复以提升可编译性。作者在 12 个 Rust crate 上评估 RustGTC,取得了较高的覆盖率并发现 41 个缺陷;同时提交了 132 个测试用例,其中 123 个被接受、9 个被拒绝。结果表明,文档化约束可有效引导 Rust API 测试生成,并揭示了边界情况上的注释与代码不一致问题。

问题
Rust API 的测试用例手工编写代价高、易出错,而现有基于 LLM 的测试生成方法未能充分利用 API 注释中记录的输入约束。
方法
从 API 注释中抽取文档化的参数约束,结合代码上下文围绕边界情况生成测试,并对生成结果进行修复以提高可编译性。
评估
在 12 个 Rust crate 上评测覆盖率与缺陷发现能力,并向相关项目提交 132 个测试用例(123 个被接受、9 个被拒绝)。
原文摘要(Abstract)

Manually crafting test cases for Rust APIs is labor-intensive and error-prone, especially because of Rust’s advanced features and complex trait system. Recent advances in large language models (LLMs) have shown promise in automated test generation; however, existing approaches often underuse documented input requirements embedded in API comments. We present RustGTC, a framework that uses API comments to guide Rust API test generation. RustGTC extracts documented parameter constraints from comments, constructs tests around boundary cases, and repairs generated tests to improve compilability. We evaluate RustGTC on 12 Rust crates, achieving high coverage and uncovering 41 defects. Additionally, we submitted 132 test cases; 123 were accepted, 9 were rejected. These results show that RustGTC uses documented constraints to guide Rust API test generation and reveal comment-code inconsistencies around boundary cases.

链接与引用

DOI 原文 · PDF(开放获取) ·

BibTeX
@inproceedings{paperbot12498,
  title = {RustGTC: Constraint-Guided Test Generation for Rust APIs via Comment Analysis and Code Context},
  author = {Yichi Zhang and Jinhao Huang and Yang Feng},
  booktitle = {ASE},
  year = {2026},
  doi = {10.1145/3832783.3837531}
}