Morest: Model-based RESTful API Testing with Execution Feedback

Yi Liu, Yuekang Li, Gelei Deng, Yang Liu, Ruiyuan Wan, Runchao Wu, Dandan Ji, Shiheng Xu, Minli Bao · DOI

Testing RESTful APIs is notoriously difficult because endpoints are rarely independent. To test a "Delete Order" function, a tester must first successfully navigate a sequence of operations, such as "Create a Pet" followed by "Place an Order." This creates a complex "call sequence" problem where the tester must understand producer-consumer dependencies between different API operations.

Existing tools typically fall into two categories: bottom-up approaches (e.g., Restler) that lack a global view and often get stuck in local optima, and top-down approaches (e.g., Resttestgen) that rely on OpenAPI specifications. However, these specifications are frequently incomplete, outdated, or ambiguous, leading to generated sequences that the actual server rejects. Morest bridges this gap by combining the global awareness of a top-down approach with the adaptive flexibility to correct its model based on real-world execution feedback.

Methodology

The core of Morest is the RESTful-service Property Graph (RPG). Unlike previous models that only considered API operations, the RPG incorporates granular schema nodes. It models not just whether "Operation A depends on Operation B," but specifically how "Operation A produces a 'Pet' object, and Operation B consumes a 'Pet ID'."

The Morest architecture overview, showing the transition from initial RPG building to test case generation and dynamic updating based on API responses.

Dynamic Model Refinement

Morest does not treat the API specification as absolute truth. Instead, it uses execution feedback to refine the RPG in real-time:

  • Edge Addition: If a server response contains data matching a known schema that was previously undocumented, Morest adds a new dependency edge to the graph.
  • Edge Deletion: If a documented dependency consistently leads to 4xx or 5xx errors, Morest identifies it as an "infeasible edge" and removes it to avoid wasting testing resources.
A refined RPG illustrating how Morest identifies dependencies between operations (e.g., addPet and getPetById) and schemas (Pet, Order), including inferred relationships represented by dashed lines.

Evaluation and Key Results

Researchers evaluated Morest against three state-of-the-art baselines (Evomaster-bb, Resttestgen, and Restler) using six diverse real-world projects, including Petstore, SpreeCommerce, Bitbucket, LanguageTool, FeatureService, and Magento. The evaluation involved 1,440 CPU hours of testing to ensure statistical significance.

Morest demonstrated a significant performance leap over existing technology:

  • Higher Efficiency: It successfully requested 152% to 232% more valid API operations than the baselines.
  • Deeper Coverage: It achieved 26% to 103% more line coverage, exploring significantly more of the underlying source code.
  • Bug Detection: It detected 44 unique bugs, 13 of which were completely missed by all other tools. Notably, two bugs found in Bitbucket were confirmed and fixed by developers, demonstrating the tool's utility on production-grade software.

Conclusion and Future Work

Morest proves that focusing on data structures (schemas) rather than just endpoints allows testing tools to bridge gaps in poor documentation. By treating the API specification as a suggestion and learning actual server behavior through feedback, Morest can explore deeper logic paths.

Future work includes improving discovery of undocumented endpoints through client-side traffic analysis and integrating more advanced "smart fuzzing" for parameter generation to uncover even more complex edge-case bugs.

Summary updated

BibTeX
@inproceedings{liu2022morest,
  author = {Yi Liu and Yuekang Li and Gelei Deng and Yang Liu and Ruiyuan Wan and Runchao Wu and Dandan Ji and Shiheng Xu and Minli Bao},
  title = {{Morest: Model-based RESTful API Testing with Execution Feedback}},
  booktitle = {ICSE},
  year = {2022},
  doi = {10.1145/3510003.3510133},
}
Figure