What Is a Contract Test?
A contract test verifies that the interaction between a service consumer and provider conforms to an agreed contract, such as the request and response shapes of an API. The consumer defines what it expects, and the provider is tested against those expectations. This catches breaking interface changes without spinning up both systems together.
Why it matters
Integration tests that run every service together are slow and flaky, yet teams still need to know that a provider change will not break its consumers. Contract tests give that assurance cheaply by checking each side against the shared contract independently, enabling services to deploy on their own schedules.
Related concepts
- Consumer-driven contracts are a common style
- Faster and more isolated than full integration tests
- Tools include Pact
Related guides
What Is a Regression Test?A regression test verifies that previously working functionality still works after a change, catching newly i…
What Is Mutation Testing?Mutation testing measures test-suite quality by deliberately introducing bugs and checking whether the tests…
What Is a Polyrepo?A polyrepo splits a codebase across many separate repositories, typically one per service or library, each wi…