Testing and reliability / Intermediate / 5 min / Updated
Contract testing: catch breaking API changes in the build
Rename, retype or remove an API field. Without contract tests consumers break in production; with them the provider build fails first.
Start the simulation → Change the load, break a part, watch what happens. Free, no sign-up.
In short
What is contract testing?
Each consumer records the fields it uses; the provider build fails if a change would break any of them.
Why does it matter?
Services break each other through API changes that pass the provider's own tests.
What is the trade-off?
Contracts catch breaks early but need upkeep; mobile clients still need versioned APIs.
How do you explain it in an interview?
"Add fields freely, never rename or remove; Pact contracts in CI; v2 for breaking changes, v1 until old apps are gone."
Check yourself
Which API change is safe for existing consumers?
Answer: Adding a new optional field. Well-behaved consumers ignore fields they do not know.
In consumer-driven contract testing, who writes the contract?
Answer: Each consumer, listing the fields and types it actually uses. The provider build then checks changes against every consumer contract.
Why can contract tests alone not protect a mobile app?
Answer: Apps already installed on phones keep the old code, so a breaking change still needs a versioned API. Keep the old version until old installs are gone.