What is consumer-driven contract testing with Pact?
Answer
Consumer-driven contract testing with Pact is a testing strategy that verifies service-to-service compatibility without requiring live integration environments. The consumer service defines a contract — a specification of the requests it makes and the responses it expects — and Pact generates a mock provider for the consumer's tests. The contract is published to a Pact Broker. The provider service's CI pipeline then verifies it can satisfy all published contracts by replaying the specified requests against its real code. If the provider changes its API in a way that breaks a consumer's contract, the CI pipeline fails before deployment. This gives teams confidence they can deploy services independently without running expensive full-stack integration tests, while still catching breaking API changes early — essential for teams operating hundreds of microservices.
Previous
What is Event Storming and how is it used to design microservices?
Next
What are the three pillars of observability in microservices?
More Microservices Architecture Questions
View all →- Advanced How does the CAP theorem apply to microservices?
- Advanced What are the trade-offs between eventual consistency and strong consistency in microservices?
- Advanced What are CRDTs and how can they help in distributed microservices state?
- Advanced What is Event Storming and how is it used to design microservices?
- Advanced What are the three pillars of observability in microservices?