Skip to content

Commit 22dc4e7

Browse files
committed
Clarify documentation on @AutoConfigureRestDocs with WebTestClient
Closes gh-15977
1 parent 1871cff commit 22dc4e7

File tree

2 files changed

+15
-6
lines changed

2 files changed

+15
-6
lines changed

spring-boot-project/spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6903,7 +6903,7 @@ It can also be used to configure the host, scheme, and port that appears in any
69036903

69046904
[[boot-features-testing-spring-boot-applications-testing-autoconfigured-rest-docs-mock-mvc]]
69056905
===== Auto-configured Spring REST Docs Tests with Mock MVC
6906-
`@AutoConfigureRestDocs` customizes the `MockMvc` bean to use Spring REST Docs.
6906+
`@AutoConfigureRestDocs` customizes the `MockMvc` bean to use Spring REST Docs when testing Servlet-based web applications.
69076907
You can inject it by using `@Autowired` and use it in your tests as you normally would when using Mock MVC and Spring REST Docs, as shown in the following example:
69086908

69096909
[source,java,indent=0]
@@ -6973,7 +6973,7 @@ The following example shows a `RestDocumentationResultHandler` being defined:
69736973

69746974
[[boot-features-testing-spring-boot-applications-testing-autoconfigured-rest-docs-web-test-client]]
69756975
===== Auto-configured Spring REST Docs Tests with WebTestClient
6976-
`@AutoConfigureRestDocs` can also be used with `WebTestClient`.
6976+
`@AutoConfigureRestDocs` can also be used with `WebTestClient` when testing reactive web applications.
69776977
You can inject it by using `@Autowired` and use it in your tests as you normally would when using `@WebFluxTest` and Spring REST Docs, as shown in the following example:
69786978

69796979
[source,java,indent=0]

spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/restdocs/AutoConfigureRestDocs.java

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2019 the original author or authors.
2+
* Copyright 2012-2020 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -23,16 +23,25 @@
2323
import java.lang.annotation.RetentionPolicy;
2424
import java.lang.annotation.Target;
2525

26+
import io.restassured.RestAssured;
27+
2628
import org.springframework.boot.autoconfigure.ImportAutoConfiguration;
2729
import org.springframework.boot.test.autoconfigure.properties.PropertyMapping;
2830
import org.springframework.context.annotation.Import;
2931
import org.springframework.core.annotation.AliasFor;
32+
import org.springframework.test.web.reactive.server.WebTestClient;
33+
import org.springframework.test.web.servlet.MockMvc;
3034

3135
/**
3236
* Annotation that can be applied to a test class to enable and configure
33-
* auto-configuration of Spring REST Docs. Allows configuration of the output directory
34-
* and the host, scheme, and port of generated URIs. When further configuration is
35-
* required a {@link RestDocsMockMvcConfigurationCustomizer} bean can be used.
37+
* auto-configuration of Spring REST Docs. The auto-configuration sets up
38+
* {@link MockMvc}-based testing of a servlet web application, {@link WebTestClient}-based
39+
* testing of a reactive web application, or {@link RestAssured}-based testing of any web
40+
* application over HTTP.
41+
* <p>
42+
* Allows configuration of the output directory and the host, scheme, and port of
43+
* generated URIs. When further configuration is required a
44+
* {@link RestDocsMockMvcConfigurationCustomizer} bean can be used.
3645
*
3746
* @author Andy Wilkinson
3847
* @since 1.4.0

0 commit comments

Comments
 (0)