← Lessons

quiz vs the machine

Platinum1750

System Design

Contract Testing Between Services

Catching integration breaks without full end to end tests.

6 min read · advanced · beat Platinum to climb

The Integration Gap

Unit tests check one service in isolation, but they miss mismatches between a service and its callers. Full end to end tests catch those but are slow and flaky. Contract testing fills the gap by verifying that a provider honors the exact shape consumers depend on.

Consumer Driven Contracts

In the common consumer driven style, each consumer records the requests it makes and the responses it expects. These expectations form a contract. The provider then runs the contract against its real implementation in its own pipeline.

What It Catches

  • A provider removing or renaming a field a consumer reads.
  • A changed status code or content type.
  • A broken assumption before it reaches production.

Why It Scales

Contract tests run fast and per service, so you do not need a full environment with every dependency up. A broker stores contracts and shows which provider versions are safe to deploy against which consumers.

Key idea

Contract testing verifies a provider against the exact expectations its consumers record, catching integration breaks fast and per service without a full end to end environment.

Check yourself

Answer to earn rating on the learn ladder.

1. In consumer driven contract testing, who defines the expected response shape?

2. A key advantage of contract testing over full end to end testing is that it is what?