Abstract
As modern web services increasingly rely on REST APIs, their thorough testing has become crucial. Furthermore, the advent of REST API documentation languages, such as the OpenAPI Specification, has led to the emergence of many black-box REST API testing tools. However, these tools often focus on individual test elements in isolation (e.g., APIs, parameters, values), resulting in lower coverage and less effectiveness in fault detection. To address these limitations, we present AutoRestTest, the first black-box tool to adopt a dependency-embedded multi-agent approach for REST API testing that integrates multi-agent reinforcement learning (MARL) with a semantic property dependency graph (SPDG) and Large Language Models (LLMs). Our approach treats REST API testing as a separable problem, where four agents — API, dependency, parameter, and value agents — collaborate to optimize API exploration. LLMs handle domain-specific value generation, the SPDG model simplifies the search space for dependencies using a similarity score between API operations, and MARL dynamically optimizes the agents' behavior. Our evaluation of AutoRestTest on 12 real-world REST services shows that it outperforms the four leading black-box REST API testing tools, including those assisted by RESTGPT, in terms of code coverage, operation coverage, and fault detection. Notably, AutoRestTest is the only tool able to trigger an internal server error in the Spotify service.
Introduction
The core challenge in REST API testing is the complex web of inter-dependencies between endpoints. To test a specific operation, such as /orders, a tester must first provide valid inputs derived from previous calls, such as a user_id from a /register endpoint. Existing automated tools often struggle with these sequences because they treat parameters in isolation, leading to a high frequency of "400 Bad Request" errors and shallow code exploration. AutoRestTest addresses this by framing API testing as a coordinated multi-agent problem.
The AutoRestTest Framework
AutoRestTest decomposes the testing process into four specialized roles, each managed by a reinforcement learning agent within a Multi-Agent Reinforcement Learning (MARL) architecture.
Specialized Agents
- Operation Agent: Prioritizes which API endpoint to explore next based on previous success or failure rates.
- Dependency Agent: Manages the Semantic Property Dependency Graph (SPDG). It uses word embeddings to calculate similarity between input and output names (e.g., mapping
user_idtoid), effectively narrowing the search space for valid API sequences. - Parameter Agent: Optimizes the combinations of optional and required parameters to maximize exploration depth.
- Value Agent: Acts as the data specialist, deciding whether to reuse previous successful values, generate random data, or leverage a Large Language Model (GPT-3.5 Turbo) for complex, domain-specific inputs.
Coordination via MARL
The system utilizes Value Decomposition Q-learning (VDN) to ensure agents work toward a collective goal. While individual agents receive rewards for successful requests (200 OK), the Operation agent receives a significant bonus for triggering a 500 Internal Server Error, aligning the "team" toward finding critical bugs.
Evaluation and Results
The researchers evaluated AutoRestTest against 12 real-world REST services, including high-traffic APIs like Spotify, FDIC, and OhSome. The tool was compared against four leading baselines: RESTler, EvoMaster, MoRest, and ARAT-RL.
Fault Detection and Coverage
AutoRestTest achieved an average of 58.3% method coverage, outperforming the next best tool by 16 percentage points. In terms of fault detection, the tool identified 42 unique internal server errors, significantly more than its competitors.
One of the most notable results was the testing of the Spotify API. AutoRestTest was the only tool capable of triggering an internal server error in the service. It achieved this by using the LLM to generate a valid 22-character Spotify ID and correctly passing that ID through a sequence of dependent calls identified by the SPDG.
Conclusion
AutoRestTest demonstrates that treating REST API testing as a separable, multi-agent problem significantly improves both coverage and bug detection. By combining the semantic reasoning of SPDGs, the generative power of LLMs, and the optimization capabilities of MARL, the framework overcomes the "isolated testing" limitations of previous tools. Future work will focus on fine-tuning smaller, specialized LLMs to reduce operational costs while maintaining high testing efficacy.
Summary updated