A service consumer and a service provider interact with each other based on some protocol or rules. This set of rules of communication between two services is called Contract and the process of testing the communication between the two services based on this Contract is called Contract Testing
The consumer creates the contract with its expectations from the provider.
The provider checks and verifies the contract.
The reason the contract is created by the consumer is that the provider may not know what exact services or information is required by a consumer and hence the contract is created by consumer and therefore it is called Consumer Driven Contract Testing
Tools for Contract Testing
There are tools for this. One of the famous tools is Pact
Source – https://medium.com/@ericjwhuang/consumer-driven-contract-testing-pact-d791a3eac72a
Contract Testing is mostly used in Microservices Architecture where we have multiple isolated services and to check the interaction and communication between these services Contract Testing is an efficient process.