API Mocking vs Stubbing: Mocks, Stubs, Fakes and Spies
Mocking vs stubbing for APIs, plus fakes, spies and service virtualization: what each test double does, when to use which, and worked examples with WireMock, MSW and Prism.
11 articles
Mocking vs stubbing for APIs, plus fakes, spies and service virtualization: what each test double does, when to use which, and worked examples with WireMock, MSW and Prism.
How to test API versioning and backward compatibility: URI, header and media-type strategies, breaking vs non-breaking changes, OpenAPI diff tools like oasdiff, consumer contracts, deprecation headers and CI gates.
What JSON Schema validation is and how it works: the 2020-12 draft and its core rules, then runnable examples validating API responses in Python (jsonschema), JavaScript (Ajv), Java (networknt, REST Assured) and Postman, how it aligns with OpenAPI 3.1, and the errors you will hit.
A practical guide to OpenAPI and Swagger API testing: how spec-driven testing works, the six kinds of tests a spec makes possible, a worked pytest and Schemathesis example against the public Petstore API, CI wiring, tools, common mistakes and a checklist.
A runnable Pact contract testing tutorial: a pact-js consumer test, publishing to a Pact Broker or PactFlow, provider verification with pact-js or pact-jvm, can-i-deploy in CI, common pitfalls, and how Pact compares with schema-first OpenAPI and bi-directional contract testing.
Pact vs Postman for contract testing — what consumer-driven contracts prove that schema assertions cannot, where Postman is genuinely enough, and how to run both.
Schema-first API development designs the OpenAPI contract before writing implementation code, enabling parallel work, auto-generated tests, mock servers, and continuous contract enforcement. The 2026 playbook for engineering teams.
What API schema validation is, how to validate requests and responses against an OpenAPI contract in tests, in CI and at the API gateway, the tools that do it (Ajv, Schemathesis, Prism, REST Assured, Postman), and how to catch schema drift.
API contract testing verifies that providers and consumers honor a shared interface contract (an OpenAPI schema or a Pact consumer contract), so breaking changes are caught in the pull request and services can deploy independently. Examples, approaches, a CI workflow and tools.