Mockmvc Articles
2 articles about Mockmvc. Explore Spring Boot implementation, design, and operations across related topics.
-
Spring Boot Test Annotations Cheat Sheet - How to Choose Between @SpringBootTest, @WebMvcTest, and @DataJpaTest
A cheat sheet and decision flow for choosing the right Spring Boot test annotation. Covers the differences in startup scope and speed between @SpringBootTest, @WebMvcTest, @DataJpaTest, @JsonTest, and @RestClientTest, with layer-by-layer explanations of how to combine them with @MockitoBean, MockMvc, and Testcontainers.
-
How to Write Controller Unit Tests with MockMvc in Spring Boot - Introduction to @WebMvcTest
Achieve fast, DB-free, copy-paste-ready Controller unit tests with @WebMvcTest and MockMvc. Explains how to mock Services with @MockBean, validate JSON with jsonPath, handle validation errors (400), and integrate Security (@WithMockUser) with practical examples.