When a web front end, a mobile app and several services call each other’s APIs, a small change in one can break another. End-to-end tests across every service catch this, but they are slow and fragile. Contract testing checks the agreements between services directly.
How it works
The consumer of an API records its expectations as a contract: which endpoints it calls, what it sends and which response fields it needs. The provider runs the contract against its own code in its build. If a change would break a consumer, the provider’s build fails before anything is deployed. Pact is the most widely used tool for this approach.
Where it pays off
- Several teams own services that call each other
- Mobile apps cannot be updated at the same moment as the API
- Partner integrations, where you need to know who uses which fields
- Migrations, where an old and a new service must behave the same way
Practical tips
Contracts should describe what the consumer really uses, not the full response, so providers stay free to add fields. Keep contracts in a shared broker, and check before each deployment that the version going live works with the consumer versions already running.
Our engineers and consultants write about what they see in real projects. Have a question about your own systems?






