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 consumer creates the Contract because the provider may not know what exact services or information a consumer requires. Since, the consumer creates the Contract and, therefore, it is called Consumer-Driven Contract Testing
Tools for Contract Testing
There are tools for this. One of the favorite tools is Pact.
Contract Testing is mainly 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.