Testing dependencies with integration testing
An application is made up of many different components; some of those components are external to the application. These external components can be other services, or they can be infrastructure that needs to be in place for the application to function properly.
It is hard to find any application built for the web that does not interact with infrastructure. Actually, it’s impossible – the web server or API gateway that the application would use to receive requests would fall into the definition of infrastructure.
We cannot test these dependencies using a unit test because if we replaced the dependency with any kind of test double, then it would not be a true test of that dependency.
In an integration test, both components are the SUT, which means we need to test with real infrastructure when possible:
Figure 10.4 – The scope of an integration test
Unlike the unit tests, which were expected...