Overview
Coursera Flash Sale
40% Off Coursera Plus for 3 Months!
Grab it
Learn to choose between MockMvcTester and RestTestClient for testing Spring Boot 4 controllers through practical demonstrations and expert guidance from the Spring team. Explore the key differences between these two testing approaches, discover when to use each one, and master practical implementation techniques including @WebMvcTest, @MakitoBean (the successor to @MockBean), and @AutoConfigureRestTestClient configuration. Practice writing tests with AssertJ-style fluent assertions while understanding the unique capabilities of each approach, from MockMvcTester's server-side inspection and multi-file upload testing to RestTestClient's unified API for mock and real environments and typed object deserialization. Examine real code examples with a Book Controller and Repository setup, compare testing methodologies side-by-side, and gain insights into when MockMvcTester excels at server-side inspection versus when RestTestClient's unified approach provides better flexibility for different testing environments.
Syllabus
0:00 - Introduction & The Question
1:15 - Project Setup with Spring Initializr
2:45 - IntelliJ IDEA 2025.3 Update
3:30 - Code Overview: Book Controller & Repository
5:00 - MockMVC Tester vs REST Test Client: Key Differences
6:30 - Writing Tests with MockMVC Tester
10:45 - Unique MockMVC Tester Capabilities
13:00 - Writing Tests with REST Test Client
17:30 - Unique REST Test Client Capabilities
20:00 - Typed Object Deserialization with REST Test Client
22:00 - Summary & Which One to Choose
Taught by
Dan Vega