12 Integration Testing
This chapter covers
- Writing integration tests
- Building reliable test suites in the presence of failures
Integration tests are essential for software that interacts with the world. They provide levels of confidence that unit tests could never. But this power comes with a price: integration testing is hard. We’re often making subtle assertions about how systems we don’t directly control should behave. And that’s the easy part. By nature of interacting with the real world, Integration tests are subject to all of its failings. We face unreliable networks, service outages, race conditions, and data corruption.
So, in this chapter we’re going to tackle how to write integration tests that are clear and reliable even in the presence of errors.
12.1 Writing Integration Tests
An integration test is any test that’s allowed to perform I/O (at least for our definition in the book). This is a small relaxation from unit tests but requires remarkably different approaches. Familiarity with integration testing seems to depend entirely on the local culture in which you were brought up. For some, they’re as natural and “obvious” as unit tests. For others, they never get exposure even after years of experience. So, here’s a quick tour.
This is an integration test.