Contract testingは、2つのサービスが完全な統合テストを実行せずにAPI上で合意していることを検証します。**consumer-driven contracts (CDC)**では、consumerが必要なものを定義し、providerがそれを提供できることを検証します。
問題
多くのサービス全体でのエンドツーエンドテストは遅く、不安定で、すべてのコミットで実行するのが難しいです。Contract testはAPIの互換性を損なう変更を早期に、隔離した状態で検出します。
CDCの仕組み(例:Pact)
text
1. Consumer writes expectations ─▶ generates a CONTRACT (Pact file)
2. Contract published to a broker
3. Provider runs the contract against itself in its own pipeline
4. Provider build FAILS if it would break the consumer
