From b8652162938f1e47b3e7b0b6fe3e60086ce804a8 Mon Sep 17 00:00:00 2001 From: Vanio Begic Date: Sun, 16 Feb 2025 09:34:57 +0100 Subject: [PATCH] Improve formatting according to the requirements in Wiki Concretely I have ensured that there are three lines between text and next header. Also I added anchors to each header Signed-off-by: Vanio Begic --- .../reference/pages/testing/testcontainers.adoc | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/spring-boot-project/spring-boot-docs/src/docs/antora/modules/reference/pages/testing/testcontainers.adoc b/spring-boot-project/spring-boot-docs/src/docs/antora/modules/reference/pages/testing/testcontainers.adoc index bdf8955402e6..487ead8c7aa0 100644 --- a/spring-boot-project/spring-boot-docs/src/docs/antora/modules/reference/pages/testing/testcontainers.adoc +++ b/spring-boot-project/spring-boot-docs/src/docs/antora/modules/reference/pages/testing/testcontainers.adoc @@ -7,6 +7,9 @@ Testcontainers is especially useful for writing integration tests that talk to a In following sections we will describe some of the methods you can use to integrate Testcontainers with your tests. + + +[[testing.testcontainers.via-junit-extension]] == Using via @Testcontainers JUnit5 extension The Testcontainers provides JUnit5 extensions, which can be used to manage containers in your tests. @@ -21,6 +24,8 @@ In most cases, you will need to configure the application to connect to the serv In this case the lifecycle of the container instance is managed by Testcontainers, as described in official documentation. + +[[testing.testcontainers.via-spring-beans]] == Using via Spring managed beans The containers provided by Testcontainers can be managed by Spring Boot as beans. @@ -35,6 +40,7 @@ then we can start the container by importing the configuration class in the test include-code::beandeclaration/SpringTest[] +[[testing.testcontainers.via-declaration-classes]] == Using via importing container declaration classes A common pattern with Testcontainers is to declare the Container instances as static fields in an interface. @@ -50,6 +56,8 @@ include-code::importcontainers/MyConfiguration[] TIP: Using interfaces for declaring contains helps with reuse. When containers are declared in an interface, this can be reused in your javadoc:org.springframework.context.annotation.Configuration[format=annotation] classes and in test classes. + +[[test.testcontainers.container-lifecycle]] == Lifecycle of managed containers If you have used the annotations and extensions provided by Testcontainers, then the lifecycle of container instances is managed by the Testcontainers. @@ -80,6 +88,8 @@ This usually happens after all tests using that specific cached application cont It is important to note that a single test container instance can be, and often is, retained across execution of tests from multiple test classes. + + [[testing.testcontainers.service-connections]] == Service Connections