# Pact 合約測試 - 確保微服務架構溝通的可靠性 - 劉奕為(John Liu) {%hackmd @HWDC/BJOE4qInR %} >#### 》[議程介紹](https://hwdc.ithome.com.tw/2024/session-page/3224) >#### 》[填寫議程滿意度問卷|回饋建言給辛苦的講者](https://forms.gle/R133iKrxT8eyDXT2A) Pact:用於測試 HTTP 和訊息整合的合約測試工具。 ## Consumer Verification - minimal response: 呈現滿足80%的case即可(ex.不然100多個field每個都要寫) ## Provider Verification / ### Pact File ### Pack mock server setup ## 實務 ### 核心整合機制(內部) - 整合用設定檔 - Consumer設定:跟哪些Provider有關係 - 工作流 - CI pipeline產生pact file - 檢查Provider diff - Provider Design - imposter Mocks - Consumer Design - Usecase Json - Base UT Framework - Mock API Call URL - CICD Pipeline ### 不想自己處理pact files - Pact Broker(要$$) - version control - dashboard - CI ### 什麼時候不用 - 只有你,團隊沒打算用(仰賴團隊認同) - Public API(unknown consumer) - Provider performance/functional testing - simple proxy/gateway