# Fast and Stable MongoDB-Based Tests in Spring

DevFeed: [Fast and Stable MongoDB-Based Tests in Spring](<https://devfeed.tech/articles/fast-and-stable-mongodb-based-tests-in-spring-17701.md>)

Original publisher: [Read original article](<https://nexocode.com/blog/posts/fast-stable-mongodb-tests-spring/>)

Author: piotr-kubowicz

Published: 2020-12-07T00:00:00Z

Content type: tutorial

Language: en

Sources: [Backend Development on nexocode](<https://devfeed.tech/sources/backend-development-on-nexocode.md>)

Topics: [MongoDB](<https://devfeed.tech/topics/mongodb.md>), [Testcontainers](<https://devfeed.tech/topics/testcontainers.md>), [Spring Boot](<https://devfeed.tech/topics/spring-boot.md>), [Database](<https://devfeed.tech/topics/database.md>), [Software Engineering](<https://devfeed.tech/topics/software-engineering.md>)

Tags: [database](<https://devfeed.tech/tags/database.md>), [embedded](<https://devfeed.tech/tags/embedded.md>), [how-to](<https://devfeed.tech/tags/how-to.md>), [kotlin](<https://devfeed.tech/tags/kotlin.md>), [linux](<https://devfeed.tech/tags/linux.md>), [mongodb](<https://devfeed.tech/tags/mongodb.md>), [performance](<https://devfeed.tech/tags/performance.md>), [software-engineering](<https://devfeed.tech/tags/software-engineering.md>), [spring](<https://devfeed.tech/tags/spring.md>), [testcontainers](<https://devfeed.tech/tags/testcontainers.md>), [testing](<https://devfeed.tech/tags/testing.md>), [tests](<https://devfeed.tech/tags/tests.md>), [tutorials](<https://devfeed.tech/tags/tutorials.md>)

## AI overview

A tutorial for replacing Flapdoodle Embedded Mongo with Testcontainers in Spring applications. It explains problems caused by multiple embedded MongoDB instances, shows how to set up MongoDB with Testcontainers, and discusses performance measurement using Linux tools.

## Source excerpt

If your Spring application uses MongoDB, there is one question you will have to answer at some point: how to set up a database instance for your tests. Until early 2020 there was not much choice and the default was to use 'embedded Mongo' - my team was no exception. At some point, however, we realised that embedded Mongo was turning our builds into a nightmare. This ultimately prompted us to migrate our code to a tool getting much hype recently - Testcontainers.