In a micro-services world, testing the successful integration between services is critical for ensuring that the services won’t fail in production just because they’re not speaking the same language.
If you develop or maintain micro-services you already asked yourself those questions :
How do we deal with testing? How do we confirm all services are working well together ?
CDC is an answer to those questions.
Let’s discover what is behind, let’s go to the upside-down !!!
Before deep diving into CDC let’s review how do we test integration between client and services at the moment.
We can use a mock of the API to design our client integrations. With mocks, we do not need to set up a whole runtime environment. We can run isolated tests between the client and a mock of the API.
To test interfaces between a client and an API the most used technique is end-to-end testing. In end-to-end tests (E2E tests), real servers or containers are set up so that client and provider are available in a production-like runtime environment.
To execute integration tests, the client is usually triggered by providing certain input in the user interface. The consumer then calls the provider and the test asserts if the results meet the expectations defined in the contract.
If we take a look at the definition of an integration test : “An integration test is a test between an API provider and an API consumer that asserts that the provider returns expected responses for a set of pre-defined requests by the consumer. The set of pre-defined requests and expected responses is called a contract.”
This is the main focus of the approach : CONTRACTS.
The whole idea behind CDC is to involve consumers of the future API in the creation of the API itself. API changes will be driven by consumers.
CDC makes your life easier :
Start by enforcing the contract without the API, then design the API accordingly : you will write less code and avoid extra features.