Integration testing

In unit testing, we test a single unit of code. In component or service testing, we test mock services depending on an external or third-party component. But integration testing in microservices can be a bit challenging, as in this type of testing we test components that work together. Service calls here should be made that integrate with external services. In this test strategy, we make sure that the system is working together correctly and the behavior of services is as expected. In our case, we have various microservices and some of them depend upon external services.

For example, StockService depends upon OrderService in a way that a particular number of items is reduced from the stock as soon as the customer successfully orders that specific item. In this scenario, when we test StockService, we should mock OrderService. Our motto should be to test StockService and not communicate with OrderService. We do not test the database of any service directly.