liveBook · Manning

MockMvc

MockMvc is a Spring testing API that simulates HTTP requests to Spring MVC components and evaluates their responses without requiring a running web server.

How 2 Manning books explain it

Spring Start Here, Second Edition

MockMvc is a Spring testing API that performs requests against Spring MVC controllers without starting a real HTTP server.

How it is used
Tests Spring MVC endpoints as part of controller integration testing.
How deep it goes
Demonstrates client configuration, request construction, and response-status checks without detailing MockMvc internals.
Examples
Uses a JSON POST to /transfer and checks for an OK response.
What you can do after
Apply MockMvc to send endpoint requests and validate responses without starting a real HTTP server.

Read how Spring Start Here, Second Edition explains MockMvc →

Spring Security in Action, Second Edition

MockMvc is a Spring testing utility that performs simulated HTTP requests against MVC application components without requiring a running server.

How it is used
Tests endpoint authorization in non-reactive Spring applications through simulated HTTP calls.
How deep it goes
Demonstrates setup, requests, response assertions, mock users, and SecurityContext behavior, while deferring reactive testing to WebTestClient.
Examples
Uses /hello requests expecting 401 Unauthorized without authentication and 200 OK with a mock user.
What you can do after
Apply it via Spring test annotations and MockMvc request builders to verify secured endpoint responses.

Read how Spring Security in Action, Second Edition explains MockMvc →

Also covered in

What to know first

Related concepts

Questions about MockMvc

What is MockMvc?

MockMvc is a Spring testing API that simulates HTTP requests to Spring MVC components and evaluates their responses without requiring a running web server.

Which Manning books explain MockMvc?

Spring Start Here, Second Edition and Spring Security in Action, Second Edition.

What should I know before learning MockMvc?

Manning books that teach MockMvc usually introduce HTTP status code first.

What is MockMvc part of?

MockMvc is part of MockMvcTester. MockMvcTester is an AssertJ-based Spring testing API for exercising Spring MVC request handling without starting an external web server.

These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.