DRIVEN
Srinivasan Sekar
Lead Consultant
ThoughtWorks
Payment
Users
{
"users":[]
}
{
"user":[]
}
Test Pyramid
Payment Service
Mocked User service
Request
Response
Targeted
Cheap
Fast
Not Trustworthy
TrustWorthy
Slow
Brittle
Whose fault ?
DRIVEN
A contract between a consumer and provider is called a pact. Each pact is a collection of interactions. Each interaction describes:
CONSUMER
API
PRODUCER MOCK
API
Request
Response
Contract
PRODUCER VERIFIER
PRODUCER
API
Request
Response
Contract
{
"user":
}
{
"users":
}
https://martinfowler.com/articles/consumerDrivenContracts.html
https://blog.testproject.io/2020/04/27/introduction-to-consumer-contract-testing/
https://blog.testproject.io/2020/05/27/consumer-driven-contract-testing-using-pact-java/
By formalizing the interaction between consumer and provider, and verifying that both services stick to the contract they’ve agreed upon, we see that we have no need to perform integration tests between them. Instead, we’re using new tests that are specific, fast, and robust.