Negative testing: every error code on demand

A test suite that only covers the happy path is testing the case that was never going to break. The catalog is built so every error is reachable on purpose: a guaranteed 500, a real rate limit, a teapot, and a fault injector that produces whatever you configure.

Negative testing — request and response sequence Sequence diagram for Negative testing: GET /pizza/v1/menu answers 400 Bad Request. PUT /pizza/v1/orders/{id}/status answers 401 Unauthorized. DELETE /protocol/v1/documents/{id} answers 403 Forbidden. POST /cargo/v1/shipments/{id}/attempt-delivery answers 404 Not Found. Your client Fun API Playground GET /pizza/v1/menu 400 Bad Request Invalid vegetarian value PUT /pizza/v1/orders/{id}/status 401 Unauthorized Missing or invalid token DELETE /protocol/v1/documents/{id} 403 Forbidden Viewer token not allowed POST /cargo/v1/shipments/{id}/attempt-delivery 404 Not Found Unknown tracking id
Real endpoints from the catalog — every request above is served, and every status code shown is one that endpoint actually returns.

How to practise it

  1. Call the Pizza oven endpoint for a reliable 500 and verify your client retries, falls back, or reports it — but does not hang.
  2. Use the Fault Injection API to set a status code, a latency and a failure rate, then run your suite against it.
  3. Separate 400 from 422: one means the request was unreadable, the other that it was understood and refused.
  4. Separate 401 from 403, and 404 from 410. Each pair is routinely collapsed, and each collapse hides a real bug.
  5. Inject a malformed body and confirm your client reports a parse error rather than crashing.

APIs to try it on

Status codes involved

Other techniques

Getting started guide · All 39 mock REST APIs

Last updated