Testcontainers (https://www.testcontainers.org) is a library that simplifies running automated integration tests by running resource managers like a database or a message broker as a Docker container. Testcontainers can be configured to automatically start up Docker containers when JUnit tests are started and tear down the containers when the tests are complete.
To enable Testcontainers in an existing test class for a Spring Boot application like the microservices in this book, we can add the @Testcontainers annotation to the test class. Using the @Container annotation, we can for example declare that the Review microservice's integration tests will use a Docker container running MySQL. The code looks like this: