Spring Framework 7 and Spring Boot 4 introduce a new RestTestClient that unifies REST API testing into a single fluent API. It combines the best of MockMVC and WebTestClient, supporting four testing modes: binding to a controller (fast unit tests, no Spring context), binding to MockMVC (slice tests with Spring MVC support for validation/security), binding to the application context (full Spring context, no server), and binding to a real server (full end-to-end with HTTP). Each mode suits different testing needs, from quick unit tests with mocked dependencies to full integration tests hitting live APIs. The RestTemplate is also being deprecated in favor of the RestClient, making this new testing infrastructure timely.

34m watch time

Sort: