Pact
Mock HTTP Server
Pact File
✳✱*
3. Basket API tests define mocks and the tests are run. This generates a Pact file.
4. This Pact file is used by the Provider Order API tests.
2. Mock Order API sends back the prearranged mock response.
How does the Provider know to run tests on Client changes?
1. Basket API tests make a request to the Mock Order API.
3. Order API independently has some contract tests. These verify that the Order API returns what other APIs (like Basket API) expect from it.
1. Basket API has Pact Consumer tests defining the relationship with Order API (requests and responses).
2. The Pact tests define this relationship using mocks.
5. Order API has one Pact Provider test.
✳✱*
There are three options to share the Pact files generated by your tests:
1. By directory path. - Good if your Consumer and Provider are in the same folder.
2. S3 Bucket or similar - Every test can access all the pacts but some management overhead.
3. Pact Broker - Pact's own service for managing Pact files.
1. The Basket API tests make requests to the Orders API.
2. Order API responds with
the information the test needs
This works... but:
QA Meet Up
Contract tests are tests created by a Provider API which verify the data objects they return for responses.
The Good
The Bad
Pact is a Framework for creating Contract tests which are validated by both a API Provider & the API Consumer