Integration testing
The overall process of writing integration tests is very similar to unit testing. The same expectations are used, the same syntax can be used, and the general guidelines/organizational structure also remains the same. The main difference comes down to what is being tested. For example, in the previous section, we created a mock so that we could limit the scope of our test. However, in an integration test, you want to use mocks sparingly such that you fully test the real integration of your types within the application.
Mocks can still be useful in cases where there is external communication involved, such as with third-party API clients whereby you do not make real requests to their servers every time the tests are run. The database layer could also be mocked but using a real test database can be very helpful, given it is a core part of an application.
A common form of integration testing is within the context of a web framework. You make a request to one...