commit
aaa26c90a8
|
@ -230,7 +230,7 @@ For convenience, tests that need to make REST calls to the started server can ad
|
||||||
|
|
||||||
include::code:MyRandomPortWebTestClientTests[]
|
include::code:MyRandomPortWebTestClientTests[]
|
||||||
|
|
||||||
TIP: `WebTestClient` can be used against both live servers and <<features#features.testing.spring-boot-applications.with-mock-environment, mock environments>>.
|
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`.
|
||||||
|
|
||||||
This setup requires `spring-webflux` on the classpath.
|
This setup requires `spring-webflux` on the classpath.
|
||||||
If you can not or will not add webflux, Spring Boot also provides a `TestRestTemplate` facility:
|
If you can not or will not add webflux, Spring Boot also provides a `TestRestTemplate` facility:
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2012-2019 the original author or authors.
|
* Copyright 2012-2032 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -26,15 +26,18 @@ import java.time.Duration;
|
||||||
|
|
||||||
import org.springframework.boot.autoconfigure.ImportAutoConfiguration;
|
import org.springframework.boot.autoconfigure.ImportAutoConfiguration;
|
||||||
import org.springframework.boot.test.autoconfigure.properties.PropertyMapping;
|
import org.springframework.boot.test.autoconfigure.properties.PropertyMapping;
|
||||||
|
import org.springframework.context.ApplicationContext;
|
||||||
import org.springframework.test.web.reactive.server.WebTestClient;
|
import org.springframework.test.web.reactive.server.WebTestClient;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Annotation that can be applied to a test class to enable a {@link WebTestClient}. At
|
* Annotation that can be applied to a test class to enable a {@link WebTestClient} that
|
||||||
* the moment, only WebFlux applications are supported.
|
* is bound directly to the application. Tests do not rely upon an HTTP server and use
|
||||||
|
* mock requests and responses. At the moment, only WebFlux applications are supported.
|
||||||
*
|
*
|
||||||
* @author Stephane Nicoll
|
* @author Stephane Nicoll
|
||||||
* @since 2.0.0
|
* @since 2.0.0
|
||||||
* @see WebTestClientAutoConfiguration
|
* @see WebTestClientAutoConfiguration
|
||||||
|
* @see WebTestClient#bindToApplicationContext(ApplicationContext)
|
||||||
*/
|
*/
|
||||||
@Target({ ElementType.TYPE, ElementType.METHOD })
|
@Target({ ElementType.TYPE, ElementType.METHOD })
|
||||||
@Retention(RetentionPolicy.RUNTIME)
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
|
|
Loading…
Reference in New Issue