diff --git a/documentation/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/testing/springbootapplications/withmockenvironment/MyMockMvcTests.kt b/documentation/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/testing/springbootapplications/withmockenvironment/MyMockMvcTests.kt index 2a09861c61d..18c92969fa1 100644 --- a/documentation/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/testing/springbootapplications/withmockenvironment/MyMockMvcTests.kt +++ b/documentation/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/testing/springbootapplications/withmockenvironment/MyMockMvcTests.kt @@ -24,6 +24,8 @@ import org.springframework.boot.test.context.SpringBootTest import org.springframework.test.web.reactive.server.WebTestClient import org.springframework.test.web.reactive.server.expectBody import org.springframework.test.web.servlet.assertj.MockMvcTester +import org.springframework.test.web.servlet.client.RestTestClient +import org.springframework.test.web.servlet.client.expectBody @SpringBootTest @AutoConfigureMockMvc @@ -35,6 +37,15 @@ class MyMockMvcTests { .hasBodyTextEqualTo("Hello World") } + @Test + fun testWithRestTestClient(@Autowired webClient: RestTestClient) { + webClient + .get().uri("/") + .exchange() + .expectStatus().isOk + .expectBody().isEqualTo("Hello World") + } + // If Spring WebFlux is on the classpath, you can drive MVC tests with a WebTestClient @Test