Chapter 5. Integration-testing microservices
This chapter covers
- Understanding integration tests in a microservices architecture context
- Differentiating between integration and component tests
- Writing integration tests for persistence layers and gateway layers
- Operating with multiple deployments in Arquillian
In the preceding chapters, you read about how to write unit and component tests for a microservices-based architecture. There are also integration tests, which in the microservices world have a meaning that’s slightly different than in other architectures.
Integration tests check the interactions between different modules (or classes), usually belonging to the same subsystem, to verify that they collaborate as expected when providing a high-level feature. Integration tests also check that all communication paths performed through the subsystem are correct, and detect any incorrect premises that each module might have about how its peers are expected to act.
Generally speaking, integration tests aren’t slow per se, but their speed depends on the logic and the interactions with modules in the subsystem under test that impact test performance. Because such subsystems usually require one or more container(s) in which to run (servlet container, CDI container, Spring container, and so forth), integration tests are slower than unit tests because they need to start and stop the container(s) they require.