"Pact" is an implementation of "consumer driven contract" testing that allows mocking of responses in the consumer codebase, and verification of the interactions in the provider codebase. The initial implementation was written in Ruby for Rack apps, however a consumer and provider may be implemented in different programming languages, so the "mocking" and the "verifying" steps would be best supported by libraries in their respective project's native languages. Given that the pact file is written in JSON, it should be straightforward to implement a pact library in any language, however, to get the best experience and most reliability of out mixing pact libraries, the matching logic for the requests and responses needs to be identical. There is little confidence to be gained in having your pacts "pass" if the logic used to verify a "pass" is inconsistent between implementations.
To support consistency of matching logic, this specification has been developed as a benchmark that all pact libraries can check themselves against if they want to ensure consistency with other pact libraries.
Pact Specificaton PhilosophyNote: One implications of this philosophy is that you cannot verify, using pact, that a key or a header will not be present in a response. You can only verify what is.
For a declarative, structured format of this version of the specification, see its JSON Schema.
Exact string match, case insensitive.
Exact string match, case sensitive, as paths are generally case sensitive. Trailing slashes should not be ignored, as they could potentially have significance.
Exact string match for expected header names and values. Allow unexpected headers to be sent out, as frameworks and network utilities are likely to set their own headers (eg. User-Agent), and it would increase the maintenance burden to have to track all of those.
Exact integer match.
Exact string match for expected header names and values. Allow unexpected headers to be sent back, as in reality, as extra headers will be added by network utilities and server frameworks.
This is an example of a pact file:
{ "provider": { "name": "Alice Service" }, "consumer": { "name": "Consumer" }, "interactions": [ { "providerState" : "Good Mallory exists", "description": "a retrieve Mallory request", "request": { "method": "GET", "path": "/mallory", "query": "name=ron&status=good" }, "response": { "status": 200, "headers": { "Content-Type": "text/html" }, "body": "\"That is some good Mallory.\"" } } ], "metadata": { "pactSpecification": { "version": "1.0.0" }, "pact-jvm": { "version": "1.0.0" } } }
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4