Autonomous Test Case Generation From API Specifications Using AI: A Hybrid LLM and Reinforcement Learning Framework
Keywords:
Autonomous Test Case Generation, OpenAPI Specification, Large Language Models, Reinforcement Learning, API Testing, Test Oracle Construction.Abstract
The exponential growth of REST API surfaces in microservice architectures has outpaced the capacity of manually authored test suites to provide meaningful specification-level coverage. Existing AI-driven test generation tools address this gap in isolation: large language model (LLM)-based approaches generate syntactically valid inputs but treat each API endpoint independently, discarding the inter-endpoint dependency semantics encoded in OpenAPI specifications; reinforcement learning (RL)-based approaches optimize test execution scheduling but presuppose that test cases already exist and leave the oracle construction problem unresolved. This article presents a hybrid autonomous test generation framework with four integrated components: a Spec-Semantic Graph (SSG) that encodes endpoint dependency relationships as a weighted directed graph; a Contextual Boundary Inference Engine (CBIE) that uses few-shot LLM prompting to extract semantic boundary conditions from natural-language description fields in OpenAPI specifications; a Coverage-Aware RL Test Scheduler (CARTS) that prioritizes test execution using a multi-dimensional coverage state vector; and Differential Oracle Synthesis (DOS) that constructs pass/fail verdicts without manually authored expected-output specifications. When evaluated on three open-source REST APIs with varying levels of specification completeness, the framework achieves higher endpoint coverage than any individual LLM-only or search-based baseline, reduces oracle false-positive rates, and incurs a one-time CI pipeline overhead that amortizes across specification versions rather than accumulating on every run. Together, the four components realize a specification-native quality assurance pipeline that derives test intelligence directly from the OpenAPI document without manual annotation.





