-
Notifications
You must be signed in to change notification settings - Fork 0
Testcontainers for Java
David Liu edited this page Jun 13, 2024
·
2 revisions
testImplementation "org.testcontainers:junit-jupiter:latest.release"
Jupiter integration is provided by means of the @Testcontainers
annotation applied to Java class.
To share containers between test method
Solution 1: Like BeforeAll and AfterAll: apply @Container
annotation on Containers java object declared as static fields.
- Containers will be started only once before any test method is executed
- Containers will be stopped after the last test method has executed.
Solution 2: Apply @Container
annotation on Containers java object declared as instance fields
- Containers will be started and stopped for every test method.
https://github.com/davidkhala/spring-common/wiki/testcontainers-for-Spring