14 / 89 · 04 API & Contract Testing with AI · Consumer-Driven Contract Testing with Pact← prev⊞ allnext →☰ Read as one page
3.2The Pact Workflow
+--------------+ +--------------+ +--------------+
| CONSUMER | | PACT BROKER | | PROVIDER |
| (Service A) | | (Registry) | | (Service B) |
| | | | | |
| 1. Write |--pact-->| 2. Store |--pact-->| 3. Verify |
| consumer | file | contract | file | provider |
| test | | | | test |
+--------------+ +--------------+ +--------------+
Step 1: Consumer Writes Tests
The consumer team writes tests that describe what they expect from the provider. These tests run against a Pact mock server, not the real provider.
Step 2: Pact Broker Stores Contracts
The generated Pact file (a JSON contract) is published to a central broker. The broker stores all consumer contracts and tracks which versions are compatible.
Step 3: Provider Verifies
The provider team runs verification tests that replay the consumer's expectations against the real provider implementation. If any expectation fails, the provider knows they would break a consumer.