Skip to content

case-contract-testing/contract-case

Repository files navigation

ContractCase Contract Testing Framework

Build and test Coverage Status Known Vulnerabilities OpenSSF Best Practices

DSL (these are the packages you want to install):

Node:

npm

Java:

Maven Central

Case

Briefcase sticker created by Gohsantosadrive on Flaticon

Read the documentation here. Documentation is currently in-progress. Feedback welcome!

ContractCase is a next-generation consumer-driven contract testing framework, building on many of the lessons from maintaining the excellent Pact contract testing framework. It is our belief that contract testing is the best way to get deployment confidence for your applications and services.

ContractCase releases follow semantic versioning, with two additional restrictions:

  1. Before 1.0.0, ContractContractCase is in Beta, and the API is considered unstable. Breaking changes will be indicated in minor version bumps- that is, 0.2.0 and 0.3.0 are not entirely compatible.
  2. Before 1.0.0, patch versions will always be backwards compatible.

Breaking changes will always be detailed in the changelog.

Incomplete documentation is here. By way of apology for the unstable API, at least one new page of documentation will be added every time a breaking change is released during the beta period.

Caveats and limitations

WARNING: THE API IS UNSTABLE AND MAY CHANGE BETWEEN MINOR VERSIONS

ContractCase is now available and should work for both client and server driven http/https contracts. Feedback on the ContractCase API / DSL and (especially) naming conventions very welcome. However, the following caveats should be kept in mind:

  1. ContractCase is currently only available in Javascript / Typescript and Java. At a later date, support for Python, C# and Go will be added. There are no plans to add other languages at this time.
  2. ContractCase doesn't yet support merging of contracts. This means that your whole contract must be defined in one test file.
  3. ContractCase currently is only compatible with Jest (js/ts) and JUnit (java).
  4. ContractCase currently only has minimal broker support. It supports the Pact broker, although the Pact broker isn't able to render ContractCase contracts yet.

Although the test coverage is high, and great care has been taken to ensure that the results are correct, there may still be bugs. Please open an issue if you experience any problems.

If you want to get started immediately, we recommend starting with either the client-driven end-to-end test, or the server-driven end-to-end test. Make sure you remove printResults: false.

You can follow the detailed progress by reading the maintainer todo list. These caveats will be updated as progress is made.

For Pact users

ContractCase has a very similar philosophy to Pact, and to maximise Pact compatibility, ContractCase works with the Pact broker. We recommend either:

ContractCase is easier to extend, can express more complex contracts, doesn't restrict where you can use matchers when defining request / response pairs, and can define contracts at either the server side or the client side (although it is always consumer driven - your consumer just might be consuming requests). See for Pact users for more discussion.

  • The Pact Broker for users wanting to host their own broke
  • The excellent Pactflow Broker for those needing SaaS and enterprise features

Internal package versions:

Command line interface::

npm Known Vulnerabilities

Definition DSL packages:

npm Known Vulnerabilities Maven Central

Connector Packages:

npm Known Vulnerabilities

Core Package:

npm Known Vulnerabilities

Roadmap

  1. Pact Parity (complete)
  2. Server driven contracts (complete)
  3. Plugins and arbitrary extensions (complete)
  4. Documentation (in progress)
  5. gRPC matchers
  6. Support Python, C# and Go
  7. Arbitrary combinations of request/response pairs, incidentally including native SQS support
  8. Pass-through APIs

For the gory details, you can see the implementation notebook / todo list here