Service integration can be a pain when providers of APIs don't have visibility into how they're being consumed. Evolving their APIs can be a slow, painful process. When a contract breaking change is released, API consumers may not find out until in production, which integration point failed and why.
Contract Tests are lightweight, easy to maintain, and quick at detecting breaking changes in API contracts. Even better are Consumer-Driven Contract Tests (CDCTs), that help consumers build their integrations based on provider contracts they expect. Serving these contracts to providers enable their creators evolve their APIs while complying with consumers' specifications.
3. Usual problem
● How to test all components work together?
● How to evolve an API with confidence?
4. Usual solution
● Fully integrated tests:
៙ Slow
៙ Hard to maintain
៙ Lots of infrastructure
៙ Hard to fix issues (which part failed?)
5. Unit tests at system boundaries?
● Make assumptions about collaborators
● Test your item of interest with those assumptions
System A
Mock
System B
System A
Actual
System B
9. Why
● Fast Feedback
៙ Detect breaking API changes early
៙ Detect what broke quickly
● Confidence to Deploy
៙ Decouple deployments
10. Why
● Enables Consumer-Driven Contract Testing
៙ TDD at a higher level!
៙ Can develop consumers before providers
៙ Providers implement only what’s needed
22. Consumer Pipeline
Commit PackageTest
Unit Test
Contract
Test
Functional
Test
Tag with
“prod”
Publish
Deploy to
Dev
Deploy to
QA
Deploy to
Prod
Publish
Contract
Tag with
“dev”
Tag with
“qa”
23. Provider Pipeline
Commit PackageTest
Unit Test
Verify
Contract
Functional
Test
Verify
Contract
Publish
Deploy to
Dev
Deploy to
QA
Deploy to
Prod
Verify
Contract
Verify
Contract
➔ ➔ ➔ ➔LATEST QADEV PROD