Merge branch '2.4.x'

Closes gh-26522
This commit is contained in:
Andy Wilkinson
2021-05-17 11:24:29 +01:00
2 changed files with 69 additions and 97 deletions

View File

@@ -929,7 +929,9 @@ include::{docs-java}/features/testing/utilities/outputcapture/MyOutputCaptureTes
==== TestRestTemplate
`TestRestTemplate` is a convenience alternative to Spring's `RestTemplate` that is useful in integration tests.
You can get a vanilla template or one that sends Basic HTTP authentication (with a username and password).
In either case, the template behaves in a test-friendly way by not throwing exceptions on server-side errors.
In either case, the template is fault tolerant.
This means that it behaves in a test-friendly way by not throwing exceptions on 4xx and 5xx errors.
Instead, such errors can be detected via the returned `ResponseEntity` and its status code.
TIP: Spring Framework 5.0 provides a new `WebTestClient` that works for <<features#features.testing.spring-boot-applications.spring-webflux-tests, WebFlux integration tests>> and both <<features#features.testing.spring-boot-applications.with-running-server, WebFlux and MVC end-to-end testing>>.
It provides a fluent API for assertions, unlike `TestRestTemplate`.