diff --git a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/anchor-rewrite.properties b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/anchor-rewrite.properties index b11e583e319..e59b2e49be9 100644 --- a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/anchor-rewrite.properties +++ b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/anchor-rewrite.properties @@ -2849,7 +2849,7 @@ howto.jedis-instead-of-lettuce # 2 == Use Testcontainers for integration testing howto-testcontainers=\ -howto.testcontainers +howto.testing.testcontainers diff --git a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/howto.adoc b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/howto.adoc index b746211c01d..2a50295f68a 100644 --- a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/howto.adoc +++ b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/howto.adoc @@ -50,5 +50,3 @@ include::howto/build.adoc[] include::howto/traditional-deployment.adoc[] include::howto/jedis-instead-of-lettuce.adoc[] - -include::howto/testcontainers.adoc[] diff --git a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/howto/testcontainers.adoc b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/howto/testcontainers.adoc deleted file mode 100644 index 03176988e8e..00000000000 --- a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/howto/testcontainers.adoc +++ /dev/null @@ -1,23 +0,0 @@ -[[howto.testcontainers]] -== Use Testcontainers for integration testing -The https://www.testcontainers.org/[Testcontainers] library provides a way to manage services running inside Docker containers. -It integrates with JUnit, allowing you to write a test class that can start up a container before any of the tests run. -Testcontainers is especially useful for writing integration tests that talk to a real backend service such as MySQL, MongoDB, Cassandra etc. -Testcontainers can be used in a Spring Boot test as follows: - -[source,java,indent=0,subs="verbatim"] ----- -include::{docs-java}/howto/testcontainers/vanilla/MyIntegrationTests.java[] ----- - -This will start up a docker container running Neo4j (if Docker is running locally) before any of the tests are run. -In most cases, you will need to configure the application using details from the running container, such as container IP or port. - -This can be done with a static `@DynamicPropertySource` method that allows adding dynamic property values to the Spring Environment. - -[source,java,indent=0,subs="verbatim"] ----- -include::{docs-java}/howto/testcontainers/dynamicproperties/MyIntegrationTests.java[] ----- - -The above configuration allows Neo4j-related beans in the application to communicate with Neo4j running inside the Testcontainers-managed Docker container. diff --git a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/howto/testing.adoc b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/howto/testing.adoc index f43303dfb22..ab606af1fc4 100644 --- a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/howto/testing.adoc +++ b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/howto/testing.adoc @@ -18,3 +18,30 @@ include::{docs-java}/howto/testing/withspringsecurity/MySecurityTests.java[] Spring Security provides comprehensive integration with Spring MVC Test and this can also be used when testing controllers using the `@WebMvcTest` slice and `MockMvc`. For additional details on Spring Security's testing support, refer to Spring Security's {spring-security-docs}#test[reference documentation]). + + + + +[[howto.testing.testcontainers]] +=== Use Testcontainers for Integration Testing +The https://www.testcontainers.org/[Testcontainers] library provides a way to manage services running inside Docker containers. +It integrates with JUnit, allowing you to write a test class that can start up a container before any of the tests run. +Testcontainers is especially useful for writing integration tests that talk to a real backend service such as MySQL, MongoDB, Cassandra etc. +Testcontainers can be used in a Spring Boot test as follows: + +[source,java,indent=0,subs="verbatim"] +---- +include::{docs-java}/howto/testing/testcontainers/vanilla/MyIntegrationTests.java[] +---- + +This will start up a docker container running Neo4j (if Docker is running locally) before any of the tests are run. +In most cases, you will need to configure the application using details from the running container, such as container IP or port. + +This can be done with a static `@DynamicPropertySource` method that allows adding dynamic property values to the Spring Environment. + +[source,java,indent=0,subs="verbatim"] +---- +include::{docs-java}/howto/testing/testcontainers/dynamicproperties/MyIntegrationTests.java[] +---- + +The above configuration allows Neo4j-related beans in the application to communicate with Neo4j running inside the Testcontainers-managed Docker container. diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/testcontainers/dynamicproperties/MyIntegrationTests.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/testing/testcontainers/dynamicproperties/MyIntegrationTests.java similarity index 93% rename from spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/testcontainers/dynamicproperties/MyIntegrationTests.java rename to spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/testing/testcontainers/dynamicproperties/MyIntegrationTests.java index 55ee89faa37..d49df7c7509 100644 --- a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/testcontainers/dynamicproperties/MyIntegrationTests.java +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/testing/testcontainers/dynamicproperties/MyIntegrationTests.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.docs.howto.testcontainers.dynamicproperties; +package org.springframework.boot.docs.howto.testing.testcontainers.dynamicproperties; import org.junit.jupiter.api.Test; import org.testcontainers.containers.Neo4jContainer; diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/testcontainers/vanilla/MyIntegrationTests.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/testing/testcontainers/vanilla/MyIntegrationTests.java similarity index 93% rename from spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/testcontainers/vanilla/MyIntegrationTests.java rename to spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/testing/testcontainers/vanilla/MyIntegrationTests.java index 454b2f0cb13..30f4a5f719f 100644 --- a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/testcontainers/vanilla/MyIntegrationTests.java +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/testing/testcontainers/vanilla/MyIntegrationTests.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.docs.howto.testcontainers.vanilla; +package org.springframework.boot.docs.howto.testing.testcontainers.vanilla; import org.junit.jupiter.api.Test; import org.testcontainers.containers.Neo4jContainer;