# Consumer-Driven Contract Test

> Consumer defines what it needs from a provider — provider proves it delivers. No end-to-end tests needed.

- **Category**: Microservices
- **Subcategory**: Testing
- **Canonical URL**: https://designpattern.fyi/patterns/consumer_side_contract_test/

---

## Description
Clean, reusable architecture pattern.


## Use Cases
Order Service (consumer) defines: "I call GET /menu/{id} and expect {id, name, price}". Restaurant Service (provider) runs Pact tests on every PR. If they remove "price", the build fails immediately.





## Trade-offs


### Advantages

- Catches breaking API changes at build time, not in prod

- No flaky end-to-end test environments needed

- Self-documenting — contracts describe actual usage

- Enables independent deployments with confidence




### Considerations & Drawbacks

- Teams need discipline to write and maintain contracts

- Pact Broker or equivalent infra needed

- Doesn't catch logic bugs — only structural/contract violations

- Learning curve for teams new to contract testing







---
**Reference**: [Original Source](https://microservices.io/patterns/testing/consumer-side-contract-test.html)

