This repository shows some samples how to integrate Testcontainers in JUnit5 tests in Spring Boot context.
It is the base for several blog posts.
It exists samples for following use cases:
- HeroClassicJDBCRepositoryIT
- HeroClassicJpaRepositoryIT
- HeroClassicJpaRepositoryReuseDatabaseIT\
- HeroSpringDataJpaRepositoryIT
- HeroSpringDataJpaRepositoryReuseDatabaseIT
- HeroRestControllerIT
If you want to run the whole Spring Boot application, you have to follow the follwing steps.
First at all, a database is needed
docker run --name my-sql -p 3306:3306 -e MYSQL_ROOT_PASSWORD=my-secret-pw -e MYSQL_DATABASE=test -e MYSQL_USER=user -e MYSQL_PASSWORD=pwd -d mysqlThen you can start the application via the spring-boot-maven-plugin:
mvn spring-boot:runAfter that, the application is available in a browser under the URL http://localhost:8080/hero