Deep dive
Contracts reduce integration surprises:
- Consumer defines expectations; provider verifies them.
- Detects breaking changes early.
- Faster than E2E, more realistic than mocks.
Examples
Consumer-driven contract flow:
Consumer publishes contract -> provider validates in CI
Common pitfalls
- Treating contracts as static and never updating them.
- Missing non-functional expectations (timeouts, retries).
- Overfitting to mocked data only.
Interview follow-ups
- How do you version and evolve contracts?
- How do you handle optional fields and backward compatibility?
- What is the difference between contract tests and schema validation?