Contract Testing¶
At integration boundaries, both sides can be tested independently against a shared contract specification - consumers specify their expectations, providers verify they meet those expectations, avoiding the need for full integration test environments.
Tension Addressed¶
Speed vs. Realism; Isolation vs. Integration
Recognizable As¶
Consumer-driven contract tests; API schema validation; provider verification against consumer expectations; contract files shared between teams
Canonical Sources¶
Robinson, "Consumer-Driven Contracts" (2006); Fowler, "IntegrationContractTest" (2011)
Transfers To¶
Legal contracts (shared expectations between parties); interface specifications; API versioning strategies; service level agreements
Contract testing occupies a middle ground: faster than full integration tests because each side tests independently, more realistic than pure unit tests because the contract represents real integration requirements. Particularly valuable for distributed systems where integration test environments are expensive.