RBCTest: Leveraging LLMs to Mine and Verify Oracles of API Response Bodies for RESTful API Testing
Hieu Huynh, Quoc-Tri Le, Tu Nguyen, Viet Nguyen, Vu Nguyen, Tien N. Nguyen
Abstract
In API testing, deriving logical constraints on API response bodies to be used as oracles is crucial in generating test cases and performing automated testing of RESTful APIs. However, existing approaches are restricted to dynamic analysis in which oracles are extracted via the execution of APIs as part of the system under test. In this paper, we propose a complementary LLM-based, static approach in which the constraints for API response bodies are mined from API specifications. We leverage large language models (LLMs) to comprehend the API specifications, mine constraints for response bodies, and generate test cases. To reduce LLMs' hallucination, we apply an Observation-Confirmation (OC) scheme which uses initial prompts to contextualize constraints, allowing subsequent prompts to more accurately confirm their presence. Our empirical results show that RBCTest with OC prompting achieves high precision in constraint mining with the average from 85.1%-93.6%. It also performs well in generating test cases from mined constraints, with a precision from 86.4%-91.7%. We also use the test cases generated by RBCTest to detect 46 mismatches between the API specification and actual response data for 19 real-world APIs. Four of the mismatches were, in fact, reported in developers' forums.
Ask about this paper
Your agent reads all of it.
Lune indexed this paper to the last equation, along with the top-tier papers that cite it. Ask a question and the answer quotes them.
Builds on9
- Chain-of-Thought Prompting Elicits Reasoning in Large Language ModelsJason Wei, Xuezhi Wang, Dale Schuurmans, Maarten Bosma et al.NeurIPS 2022 · 22,562 citations
- Automated test generation for REST APIs: no time to rest yetMyeongsoo Kim, Qi Xin, Saurabh Sinha, Alessandro OrsoISSTA 2022 · 67 citations
- Morest: Model-based RESTful API Testing with Execution FeedbackYi Liu, Yuekang Li, Gelei Deng, Yang Liu et al.ICSE 2022 · 52 citations
- Combinatorial Testing of RESTful APIsHuayao Wu, Lixin Xu, Xintao Niu, Changhai NieICSE 2022 · 47 citations
- Online testing of RESTful APIs: promises and challengesAlberto Martin-Lopez, Sergio Segura, Antonio Ruiz-CortésFSE 2022 · 34 citations
Related papers
- SATORI: Static Test Oracle Generation for REST APIsJuan C. Alonso, Alberto Martin-Lopez, Sergio Segura, Gabriele Bavota et al.ASE 2025 · 2 citations
- Speculate: Generating REST API Specifications using LLMsKrishanu Singh, Kushagra Karar, Abhilash Jindal, Guowei YangFSE 2026
- RESTOR: Automated Test Oracle Generation for RESTful APIs via Reinforcement LearningXun Zhou, Zhen Dong, Mingyu Ren, Qiang Li et al.ISSTA 2026
- The Midas Touch: Triggering the Capability of LLMs for RM-API Misuse DetectionYi Yang, Jinghua Liu, Kai Chen, Miaoqian LinNDSS 2025
- Enhancing REST API Testing with NLP TechniquesMyeongsoo Kim, Davide Corradini, Saurabh Sinha, Alessandro Orso et al.ISSTA 2023 · 34 citations
