diff --git a/complete/build.gradle b/complete/build.gradle
index 9ba2747..d66f735 100644
--- a/complete/build.gradle
+++ b/complete/build.gradle
@@ -15,6 +15,9 @@ repositories {
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-data-mongodb'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
+ testImplementation 'org.springframework.boot:spring-boot-testcontainers'
+ testImplementation 'org.testcontainers:junit-jupiter'
+ testImplementation 'org.testcontainers:mongodb'
}
test {
diff --git a/complete/pom.xml b/complete/pom.xml
index 8ac0f78..e955c5b 100644
--- a/complete/pom.xml
+++ b/complete/pom.xml
@@ -27,6 +27,21 @@
spring-boot-starter-test
test
+
+ org.springframework.boot
+ spring-boot-testcontainers
+ test
+
+
+ org.testcontainers
+ junit-jupiter
+ test
+
+
+ org.testcontainers
+ mongodb
+ test
+
diff --git a/complete/src/test/java/com/example/accessingdatamongodb/CustomerRepositoryTests.java b/complete/src/test/java/com/example/accessingdatamongodb/CustomerRepositoryTests.java
index 5a12c67..43965da 100644
--- a/complete/src/test/java/com/example/accessingdatamongodb/CustomerRepositoryTests.java
+++ b/complete/src/test/java/com/example/accessingdatamongodb/CustomerRepositoryTests.java
@@ -24,14 +24,21 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.boot.testcontainers.service.connection.ServiceConnection;
import org.springframework.data.domain.Example;
-import com.example.accessingdatamongodb.Customer;
-import com.example.accessingdatamongodb.CustomerRepository;
+import org.testcontainers.containers.MongoDBContainer;
+import org.testcontainers.junit.jupiter.Container;
+import org.testcontainers.junit.jupiter.Testcontainers;
@SpringBootTest
+@Testcontainers
public class CustomerRepositoryTests {
+ @Container
+ @ServiceConnection
+ static MongoDBContainer container = new MongoDBContainer("mongo:7.0.2");
+
@Autowired
CustomerRepository repository;