Skip to content

Commit 97c2311

Browse files
committed
Merge branch '3.1.x'
Closes gh-38114
2 parents da078d1 + 3be8475 commit 97c2311

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ For convenience, tests that need to make REST calls to the started server can ad
231231

232232
include::code:MyRandomPortWebTestClientTests[]
233233

234-
TIP: `WebTestClient` can be used against both live servers and <<features#features.testing.spring-boot-applications.with-mock-environment, mock environments>>.
234+
TIP: `WebTestClient` can also used with a <<features#features.testing.spring-boot-applications.with-mock-environment, mock environment>>, removing the need for a running server, by annotating your test class with `@AutoConfigureWebTestClient`.
235235

236236
This setup requires `spring-webflux` on the classpath.
237237
If you can not or will not add webflux, Spring Boot also provides a `TestRestTemplate` facility:

spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/reactive/AutoConfigureWebTestClient.java

+6-3
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-2032 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.
@@ -26,15 +26,18 @@
2626

2727
import org.springframework.boot.autoconfigure.ImportAutoConfiguration;
2828
import org.springframework.boot.test.autoconfigure.properties.PropertyMapping;
29+
import org.springframework.context.ApplicationContext;
2930
import org.springframework.test.web.reactive.server.WebTestClient;
3031

3132
/**
32-
* Annotation that can be applied to a test class to enable a {@link WebTestClient}. At
33-
* the moment, only WebFlux applications are supported.
33+
* Annotation that can be applied to a test class to enable a {@link WebTestClient} that
34+
* is bound directly to the application. Tests do not rely upon an HTTP server and use
35+
* mock requests and responses. At the moment, only WebFlux applications are supported.
3436
*
3537
* @author Stephane Nicoll
3638
* @since 2.0.0
3739
* @see WebTestClientAutoConfiguration
40+
* @see WebTestClient#bindToApplicationContext(ApplicationContext)
3841
*/
3942
@Target({ ElementType.TYPE, ElementType.METHOD })
4043
@Retention(RetentionPolicy.RUNTIME)

0 commit comments

Comments
 (0)