← Lessons

quiz vs the machine

Platinum1780

System Design

The Contract Testing

Catch breaking API changes between services without full integration runs.

5 min read · advanced · beat Platinum to climb

The integration test problem

Spinning up every service together to test interactions is slow, flaky, and hard to maintain. Yet you still must catch when a provider breaks a consumer.

What a contract is

A contract captures the expectations between a consumer and a provider: the requests the consumer sends and the responses it expects.

Consumer driven contracts

In the common style, the consumer defines its expectations and shares them. The provider then runs the contract against itself in its own pipeline.

  • If the provider still satisfies the contract, the integration is safe.
  • If a provider change breaks the contract, its build fails before deploy.

Why it scales

Each side tests against the shared contract independently, with no need to run everything together. This catches breaking changes early while keeping tests fast and isolated.

Key idea

Contract testing verifies each provider against shared consumer expectations independently, catching breaking API changes without slow full integration runs.

Check yourself

Answer to earn rating on the learn ladder.

1. What does a contract capture in contract testing?

2. Why does contract testing scale better than full integration tests?