practice

Contract Testing

Verifying that a provider satisfies the expectations each of its consumers actually relies on, without running all the services together.

testingintegrationci

The problem it solves: end-to-end integration environments are slow, flaky and expensive, and they still only test the paths somebody thought to exercise.

In consumer-driven contract testing, each consumer records the requests it makes and the parts of the response it depends on. Those expectations are published, and the provider's own build verifies it can satisfy every one of them. A provider whose change breaks a consumer finds out in its own pipeline, in seconds, before merge.

The subtle strength is that it captures what consumers actually use, not what the API documents. A field nobody reads can be removed safely; a field one consumer depends on cannot — and without contract tests, nobody knows which is which.