Skip to content

Resource · Guide or article

Consumer-Driven Contract Testing (CDC)

Explains consumer-driven contract testing, where a consumer's tests against a provider mock produce a contract that the provider later verifies against its real responses. Useful for backend engineers who need to discuss how services that call each other are tested without leaning on slow end-to-end suites.

Reviewed

Open the original: Consumer-Driven Contract Testing (CDC) (opens the original site in a new tab)

Add to a roadmap

Keep this resource with a roadmap you follow. It appears as your own extra resource; the roadmap's steps don't change and it doesn't count toward your tracked steps.

Source content: English

Consumer-driven Contract Testing (or CDC for short) is a software testing methodology used to test components of a system in isolation while ensuring that provider components are compatible with the expectations that consumer components have of them.

PrepKit overview

PrepKit editors wrote and reviewed this overview from the source repository. It is not text from the resource itself.

Suited to
The source does not state a level
Format
Guide

What it covers

  • Why teams adopt CDC: end-to-end tests are slow, brittle, costly to maintain and often need a dedicated environment
  • The three building blocks in order: consumer tests with a provider mock, the generated contract, and provider contract verification
  • How a contract differs from an OpenAPI specification: a spec describes structure, a contract pins an expected response to a given request
  • Two causes of a failed provider verification: wrong consumer expectations or a provider regression
  • Pact and Spring Cloud Contract as tooling, plus drawbacks such as training cost and keeping business logic out of contract tests

How to use it

PrepKit study advice, not a claim made by the source.

Take two services you have built or studied, one calling the other, and sketch the consumer test, the contract file and the provider check on paper. You are ready when you can explain in an interview why a contract test would catch a renamed response field before deployment and an end-to-end test would catch it later.

Scope and limitations

Written as team engineering guidance, not as interview preparation. It has no code samples of its own; the worked examples are external links (a Java Pact project and a .NET workshop). Tool coverage is limited to Pact and Spring Cloud Contract.

Access and format

Free English web page in Microsoft's Code-With Engineering Playbook on microsoft.github.io (CC BY 4.0 repository).

Reviewed by PrepKit on Oct 2, 2026. Listing source commit: 016770e43d8a

Evidence behind this overview
  • docs/automated-testing/cdc-testing/README.md

Pages that include this

Get the PrepKit newsletter

Optional. You don't need it to use PrepKit.

How we handle your email