arXivDaily arXiv每日学术速递 周一至周五更新
感恩节,周五至周末无更新,大家顺遂。周一再来吧
arXiv 2606.00530cs.SE
收藏

Sakura: 一种从自然语言测试描述生成复杂测试的方法

Sakura: An Approach for Generating Complex Tests from Natural Language Test Descriptions

Georgia Institute of Technology(佐治亚理工学院);IBM Research(IBM研究院);University of Georgia(佐治亚大学)

Tyler Stennett, Rangeet Pan, Bridget McGinn, Alessandro Orso, Saurabh Sinha

AI总结:

提出基于多智能体框架Sakura,从自然语言描述生成结构复杂的测试用例,通过分解描述、静态分析定位、迭代合成与执行反馈,显著提升测试可编译性和覆盖率。

摘要:

测试是软件开发工作流中的核心活动,其自动化研究已持续数十年。现有方法大多针对单个方法生成单元测试、验证隔离的API端点或面向用户界面层,而非API和非UI的自动测试生成器通常仅执行单个焦点方法。最近的实证证据表明,此类生成的测试与开发者编写的测试之间存在显著差距,后者通常涉及多个焦点方法、复杂的调用序列以及当前自动化方法无法捕获的精细断言。为弥补这一差距,我们提出从开发者意图的自然语言描述生成测试。我们提出了Sakura,这是首个基于智能体的框架,用于从自然语言描述生成结构复杂的测试用例。Sakura将自然语言描述分解为结构化块,并使用多智能体系统进行处理,该系统包括:通过静态分析将测试步骤定位到具体应用代码的定位智能体、合成可编译测试代码并通过执行反馈迭代精炼的组合智能体,以及协调智能体交互的监督智能体。为评估Sakura,我们整理了一个包含三个抽象级别自然语言测试描述的新数据集,这些描述是从Apache Commons项目中挖掘的开发者编写的测试中系统生成的。在20个应用程序和1,464个测试场景中,Sakura显著优于现成的智能体工具(如Gemini CLI)。具体而言,与使用相同模型的基线相比,Sakura的测试可编译性提高了50-78%,与真实测试的覆盖率重叠提高了38-66%。此外,Sakura搭配小型开源模型(如Devstral Small 2和Qwen3-Coder)在使用大型专有模型的Gemini CLI上表现更优,同时更具成本效益。

英文摘要:

Research on automating software testing has spanned several decades. Most existing approaches generate unit tests for individual methods, validate isolated API endpoints, or target user interface (UI) layers, with non-API and non-UI generators typically exercising only a single focal method. Recent empirical evidence shows a substantial gap between such generated tests and developer-written ones, which often span several focal classes and methods, involve multi-step call sequences, and contain chained assertions, all characteristics that current approaches fail to capture. To address this gap, we propose generating tests from natural language (NL) descriptions of developer intent, an expressive and accessible medium for specifying complex test scenarios. We present Sakura, the first agent-based framework for generating structurally complex tests from NL descriptions. Sakura decomposes NL descriptions into structured blocks and processes them with a multi-agent system: a localization agent grounds test steps in concrete application code via static analysis, a composition agent synthesizes compilable test code and iteratively refines it using execution feedback, and a supervisor agent coordinates their interactions. To evaluate Sakura, we curate a novel dataset of NL test descriptions at three levels of abstraction, reflecting different end-user personas, systematically derived from developer-written tests in Apache Commons projects. Across 20 applications and 1,464 test scenarios, Sakura substantially outperforms off-the-shelf agentic tools such as Gemini CLI instantiated with multiple LLMs, achieving 50-78% higher test compilability and 38-66% higher coverage overlap with ground-truth tests using the same models. Moreover, Sakura paired with small open-source models such as Devstral Small 2 and Qwen3-Coder outperforms Gemini CLI using large proprietary models, at lower cost.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑