contract testing

Testing that an API’s real behaviour matches its written contract, and that its callers only rely on what the contract promises.

In more detail

Provider checks prove the service serves what the contract says; consumer checks record what real callers need. Run them before every deployment so an incompatible change fails in review, not in a client. Deliberately breaking the service and watching the checks fail proves they have teeth.

Examples

Validating real server responses against the shared Zod schema in CI and failing the build on any mismatch.
In this course: The consumer records the requests it sends and the responses it needs; the provider replays them against its implementation. A renamed field or changed status then fails before deployment. Treat a failure as a compatibility decision: fix the provider, migrate the consumer or version the contract.

Related terms

Taught in

References