RESTOR: Automated Test Oracle Generation for RESTful APIs via Reinforcement Learning
Xun Zhou, Zhen Dong, Mingyu Ren, Qiang Li, JunJie Li, Sifan Wang, Xiaolong Yu, Chaofeng Sha, Xin Peng
Abstract
Modern REST API testing faces a critical challenge in defining reliable test oracles, particularly in agile industrial environments where formal specifications (e.g., OpenAPI) are frequently missing or outdated, and historical execution logs are unavailable for newly deployed endpoints. In this paper, we present Restor (Reinforcement Enhanced Single-Traffic Oracle generator for REST APIs), a framework that generates executable test assertions from a single observed request-response pair in a black-box setting. Unlike existing approaches that rely on rule-based templates or massive training logs, Restor utilizes a novel data augmentation pipeline to fine-tune a lightweight Large Language Model (LLM) via Group Relative Policy Optimization (GRPO). This training process enables the model to internalize testing "common sense" by optimizing a reward function that jointly encourages: (i) the selection of stable, semantically meaningful fields for validation and the avoidance of dynamic noise (e.g., timestamps or trace IDs); (ii) the generation of robust assertions that withstand logic variations. We evaluate Restor on an industrial dataset comprising over 2,300 API traces across 246 real-world services. Comprehensive experiments demonstrate that Restor significantly outperforms prompt-engineered baselines and generalist models, achieving a superior F1 score of 85.42% in key field identification and increasing the proportion of semantically accurate assertions. Furthermore, deployment in a production CI/CD workflow at ByteDance confirms its practical value: the system raised the adoption rate of automatically generated test cases from 74.1% to over 96%, substantially reducing manual Quality Assurance (QA) effort while ensuring high execution stability.
Create a lesson
Related papers
Automated Testing and Repair for Verified Compilers Generated by a Coding Agent
Shared title terminology · Martin Rinard
From Industrial Product Documentation to Automated Digital Product Passport Generation: An Experimental Study of Large Language Models
Shared title terminology · Marco Buecheler, Grant Richards, Nathan Hartman
Compiled AI: Deterministic Code Generation for LLM-Based Workflow Automation
Shared title terminology · Geert Trooskens, Aaron Karlsberg, Anmol Sharma et al.
Automated Table Reproduction via Code Generation
Shared title terminology · Doehyun Baek, Michael Pradel
How well LLM-based test generation techniques perform with newer LLM versions?
Shared title terminology · Michael Konstantinou, Renzo Degiovanni, Mike Papadakis
Evaluating and Mitigating the Misguidance Effect of Buggy Code in LLM-Generated Unit Tests
Shared title terminology · Junda Zhao, Shurui Zhou, Eldan Cohen