Spring Boot 3.1.0 introduced support for Testcontainers to simplify local development and testing. Testcontainers helps in writing tests using real dependencies instead of mocks, but it may also increase the test execution time. In this article, I will share some insights on how to reduce test execution time while using Testcontainers. Sample Spring Boot application Let’s assume you have created a Spring Boot project using Spring Initializr by selecting Spring Web, Spring Data JPA, PostgreSQL, Flyway and Testcontainers.
Continue reading »SpringBoot Integration Testing using TestContainers Starter
One of the many reasons for huge popularity of Spring and SpringBoot is it’s great support for Testing. We can write unit tests using Mockito without requiring any Spring features. And, we can write Integration Tests using Spring testing support by creating Spring ApplicationContext. Read Guide to Testing SpringBoot Applications While running integration tests we might need to interact with external services like relational databases, NoSQL datastores, Kafka etc. We can spin up those external services as Docker containers and run tests against them.
Continue reading »