What is contract testing?

Contract testing is a technique for testing software application interfaces and integrations.

When used in the context of an integration, contract testing ensures that a pair of applications will work correctly together by checking each application in isolation to ensure the messages it sends or receives conform to a shared understanding that is documented in a "contract".

When used in the context of a single application, contract testing ensures that an application's behaviour conforms to its documented contract (for example, an Open API specification) without reference to any particular consumer.

The parties involved in an integration contract are called the "consumer" (the application that makes use of the functionality or data of the other) and the "provider" (the application that provides functionality or data for the other application to use).

Integration contract testing can be used to test any type of software integration, however, its increased relevance and usage over the last few years has been primarily driven by the rise in popularity of HTTP and messaging microservices.

Contracts are typically either "provider driven" (where the team responsible for the provider application maintains and shares the contract with its consumers) or "consumer driven" (where the teams responsible for the consumers maintain and share the contracts).

Next: What is consumer driven contract testing?

New feature alert: learn about bi-directional contract testing

arrow-up icon