Spring Boot - Testing a Data MongoDB application with Testcontainers and @DataMongoTest
In this section, we will learn how to test Repository layer components with @DataMongoTest and Testcontainers in Spring Boot Data MongoDB application that uses MongoDB as database. 1. What we will build? We will create a basic Data MongoDB Spring Boot application that uses MongoDB as database. We will create Repository layer for this application. Finally we will do a testing with help of Testcontainers and @DataMongoTest to verify our system is working as expected. 2. Testcontainers Testcontainers is an open source testing library that allows us to run docker containers directly in our spring boot application in order to facilitate integration tests with real dependencies. It can provide instances of common databases(here MongoDB), message brokers, Selenium web browsers, or anything else that can run in a Docker container. 3. @ DataMongoTest Instead of bootstrapping the entire application context for every test, @DataMongoTest allows us to initialize ...