11 Implementing provider-driven contract testing
This chapter covers
- Introduction to provider-driven contract testing
- Implementing consumer test adapters
- Implementing provider tests with API testing tools
As mentioned in chapter 1, section 1.4, consumer-driven contract testing (CDCT) is when the consumer creates the contract and shares it with the data providers, essentially driving the requirements. The consumer-driven approach aims to avoid over-engineering from the provider side by only providing the data the consumer needs. Throughout chapter 2, we provide the benefits of adopting CDCT, and, in chapter 6, we talk about provider tests that verify consumer contracts. However, we also mentioned that the CDCT approach only works with good team communication and buy-in, and there could be scenarios where teams can’t adopt this approach.
For instance, imagine that in the web consumer example used in chapter 1, the consumer has decided to use a third-party data provider who provides random images of dogs, as shown in figure 11.1.