mirror of
https://github.com/spring-projects/spring-boot.git
synced 2024-08-29 03:06:45 +08:00
Clarify documentation on @AutoConfigureRestDocs with WebTestClient
Closes gh-15977
This commit is contained in:
parent
1871cffc7d
commit
22dc4e7608
@ -6903,7 +6903,7 @@ It can also be used to configure the host, scheme, and port that appears in any
|
||||
|
||||
[[boot-features-testing-spring-boot-applications-testing-autoconfigured-rest-docs-mock-mvc]]
|
||||
===== Auto-configured Spring REST Docs Tests with Mock MVC
|
||||
`@AutoConfigureRestDocs` customizes the `MockMvc` bean to use Spring REST Docs.
|
||||
`@AutoConfigureRestDocs` customizes the `MockMvc` bean to use Spring REST Docs when testing Servlet-based web applications.
|
||||
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:
|
||||
|
||||
[source,java,indent=0]
|
||||
@ -6973,7 +6973,7 @@ The following example shows a `RestDocumentationResultHandler` being defined:
|
||||
|
||||
[[boot-features-testing-spring-boot-applications-testing-autoconfigured-rest-docs-web-test-client]]
|
||||
===== Auto-configured Spring REST Docs Tests with WebTestClient
|
||||
`@AutoConfigureRestDocs` can also be used with `WebTestClient`.
|
||||
`@AutoConfigureRestDocs` can also be used with `WebTestClient` when testing reactive web applications.
|
||||
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:
|
||||
|
||||
[source,java,indent=0]
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2019 the original author or authors.
|
||||
* Copyright 2012-2020 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@ -23,16 +23,25 @@ import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
import io.restassured.RestAssured;
|
||||
|
||||
import org.springframework.boot.autoconfigure.ImportAutoConfiguration;
|
||||
import org.springframework.boot.test.autoconfigure.properties.PropertyMapping;
|
||||
import org.springframework.context.annotation.Import;
|
||||
import org.springframework.core.annotation.AliasFor;
|
||||
import org.springframework.test.web.reactive.server.WebTestClient;
|
||||
import org.springframework.test.web.servlet.MockMvc;
|
||||
|
||||
/**
|
||||
* Annotation that can be applied to a test class to enable and configure
|
||||
* auto-configuration of Spring REST Docs. Allows configuration of the output directory
|
||||
* and the host, scheme, and port of generated URIs. When further configuration is
|
||||
* required a {@link RestDocsMockMvcConfigurationCustomizer} bean can be used.
|
||||
* auto-configuration of Spring REST Docs. The auto-configuration sets up
|
||||
* {@link MockMvc}-based testing of a servlet web application, {@link WebTestClient}-based
|
||||
* testing of a reactive web application, or {@link RestAssured}-based testing of any web
|
||||
* application over HTTP.
|
||||
* <p>
|
||||
* Allows configuration of the output directory and the host, scheme, and port of
|
||||
* generated URIs. When further configuration is required a
|
||||
* {@link RestDocsMockMvcConfigurationCustomizer} bean can be used.
|
||||
*
|
||||
* @author Andy Wilkinson
|
||||
* @since 1.4.0
|
||||
|
Loading…
Reference in New Issue
Block a user