LLM-Written API Tests Falter on Vague Requirements and Buggy Code
RESTestBench scores LLM-written REST API tests by whether they catch requirement-specific bugs. Vague requirements cut scores sharply, and refining tests against a buggy service made them miss more faults.
TL;DR
- RESTestBench checks whether LLM-written REST API tests catch 228 hand-made, requirement-specific bugs across three open-source services and 106 requirements [^1].
- With vague requirements, scores typically fell by 26 to 40 points, and refining tests against buggy code made them miss more faults [^1].
Background
REST API testing tools have mostly been judged by code coverage and crash signals such as HTTP 5xx server errors [^1]. Newer LLM-based tools write tests from natural-language requirements, aiming to check business logic instead [^1]. For that, the authors argue, the old metrics are weak proxies: they show how much of a system a test exercises, not whether it checks the intended behavior [^1]. Mutation testing, which plants small faults and counts how many a test catches, is a stronger signal [^1].
What happened
Researchers from CASABLANCA hotelsoftware, the University of Innsbruck, the Technical University of Munich and Diffblue posted RESTestBench on arXiv in April [^1]. It bundles three open-source services: a FastAPI full-stack template in Python, a compact .NET TodoApp and a NestJS implementation of the RealWorld API [^1]. For these, the authors wrote 106 requirements, each in a precise version that spells out every step and expected value and a vague one that states only the goal, plus 228 hand-made mutations [^1]. Each mutation breaks one specific requirement, following the property-based mutation testing of Bartocci et al.: a test only gets credit when it catches the violation of that requirement [^1]. One example swaps the email addresses among users in a list response, so a test that only checks that the emails are present misses it [^1].
The team tested ten models, from Llama 3.1 8B and GPT-5 Nano to Claude Sonnet 4.5, and ran each experiment three times [^1]. In the single-step setup, a model gets the requirement, the OpenAPI specification and the service address and writes a pytest test in one go. On precise requirements, scores ranged from 13 percent for Llama 3.1 8B to 92 percent for Sonnet 4.5. On vague ones, they typically dropped by 26 to 40 percentage points, and the best models clustered between 49 and 54 percent [^1].
In the refinement setup, the test runs against the live service, and a second call to the same model reviews the output and the HTTP trace, then accepts the test or asks for a revision, for up to three rounds [^1]. That helped most on vague requirements: GPT-5 Nano gained 29 points to reach 80 percent [^1]. But when the test was generated against a service that already contained the planted bug, scores were consistently lower, and for four models on precise requirements, including Sonnet 4.5 and GPT-5 Nano, plain single-step generation beat refinement against the faulty service [^1]. The authors' plausible explanation: the model adapts its assertions to the faulty behavior and treats the defect as correct [^1].
Why it matters
The results question a common design. Several tools the paper surveys, among them LogiAgent, SAINT and RESTifAI, refine their tests against the running service [^1]. The authors argue that a requirements-based test must be able to tell a valid system from a faulty one, which it cannot do if it takes the current behavior as the truth [^1]. Their data show refinement pulling tests toward whatever the code does, more so when the requirement leaves room for interpretation [^1]. Most surveyed tools also let an LLM write the requirements, without validation, so the authors expect correctness to drop further there [^1].
Cost and failure modes add nuance. Refinement raised generation costs roughly two- to fourfold. On vague requirements, GPT-5 Nano in a refinement loop reached 70 percent at $0.41 per run, ahead of Sonnet 4.5 at 65 percent for $10.13 [^1]. The models also failed differently: the Llama models wrote broken tests, with wrong status codes, invented endpoints or leftover placeholder values, while Sonnet 4.5 wrote clean code that assumed REST conventions the service didn't follow, such as expecting status 422 where it returns 400 [^1]. No model passed the common 90 percent bar for a good test suite on vague requirements, and the study is limited to three services, Python tests and three runs per experiment [^1].
Practical example
Say Priya maintains the booking API for a small hotel software firm. A new requirement arrives from the product team as a single line: guests can cancel a booking, and the test should verify the response. Priya hands it, with the OpenAPI specification, to an LLM test generator with a refinement loop, the kind of setup RESTestBench tested [^1].
Last week, a teammate's change broke cancellation: the endpoint reports success, but the booking stays active. The generator writes a first test that asserts the booking is gone, runs it against the service and reads the HTTP trace. The test fails, and the review step has to decide whether the test or the service is wrong [^1]. The vague requirement doesn't say what cancelling should do to the booking, so the model does what the paper observed: it adapts its assertions to the faulty behavior and treats the defect as correct [^1]. The refined test passes, and the bug ships with a green check mark.
The fix follows from the paper's two findings. Priya rewrites the requirement in the precise style, listing each step and the expected response fields, including the booking's status after cancellation; precise requirements raised scores for every model tested [^1]. And because single-step generation from precise requirements beat refinement against a faulty service for four models, Priya generates the test without letting the model see the service first [^1]. This time the test fails, as it should, and the broken cancellation never reaches guests.
Related gear
We recommend this book because it explains test adequacy and mutation testing, the ideas RESTestBench builds its scoring on, and it is the source of the 90 percent bar the paper cites.