Contract testing checks that a service and its clients agree on an interaction API without testing them together. It supports independent deployment while detecting changes that break client expectations or client usage that violates the contract. section 7.3.1
Testing a service in isolation also requires accurate simulations of its clients and collaborators. Simple, well-defined, stable APIs make these simulations easier to maintain; contract tests check that the service implements and uses the expected APIs. section 7.3.1
In consumer-driven contract testing:
- Client teams provide contracts that check the service API against their clients’ expectations. section 8.1.5
- The provider team adds those contracts to its automated test suite and runs them when the service implementation changes. section 8.1.5
- Client-side contract tests check that clients can communicate with the service. Run checks on developer machines and in the deployment pipeline. section 7.6.2 section 8.1.5
An API change between services
The Order Service depends on the Consumer Service. A contract test can fail if a Consumer Service API change breaks what the Order Service expects, or if the Order Service uses the API in a way that violates the contract. If every client supplies contracts, a change that passes them—including removing a field no client depends on—can be treated as non-breaking. section 7.3.1 section 8.1.5
Contract tests add maintenance overhead, but avoid relying solely on complex, slow, brittle end-to-end tests for interaction checks. Schema comparison is another way to detect breaking changes; consumer-driven contracts instead check compatibility against client expectations. section 7.3.1 section 7.6.2 section 8.1.5






