This repository contains sample projects that use Testcontainers with different technologies. I hope it will help you use it in your own projects.
All samples are build with Kotlin, Gradle & JUnit 5.
👉 If you use JDK 17+ & Spring Boot 3.1+ go straight to the simplest project. Other projects use older Spring Boot 2.7 to show how to use Testcontainers without all great advancements that since were made. As for now, 2.7 is still commercially supported until 2025-08-24. I encourage you to update Spring Boot according to the official support timeline to have the best experience with Testcontainers and what not.
- NEW! [Spring Boot 3.1+]: The simplest Spring MVC, JPA on PostgreSQL & local running
- [Spring Boot 2.7]: MVC & JPA with PostgreSQL
- [Spring Boot 2.7]: MVC & JPA with Kotest tests
- [Spring Boot 2.7]: MVC & JPA with PostgreSQL & local running
- [Spring Boot 2.7]: Kafka with local running
./gradlew check
./gradlew kafka:check
./gradlew local-db:check
./gradlew spring6-junit5:check
./gradlew spring-junit5:check
./gradlew spring-kotest:check
💥 NEW! To run locally application with a Postgresql container configured by Testcontainers & Spring Boot 3.1+.
./gradlew spring6-junit5:bootTestRun
To run locally application with a Kafka container configured by Testcontainers.
./gradlew kafka:bootLocalRun
To run locally application with a Postgresql container configured by Testcontainers.
./gradlew local-db:bootLocalRun
If you got ContainerFetchException
because of failing Docker environment should have more than 2GB free disk space
,
increase available disc space in Docker for Mac. See more.