Performance: @WebMvcTest for controller testing
MEDIUM IMPACT
This affects test execution speed and resource usage during controller testing by limiting loaded components.
@WebMvcTest(UserController.class) public class UserControllerTest { @Autowired private MockMvc mockMvc; // tests }
@SpringBootTest
@AutoConfigureMockMvc
public class UserControllerTest {
@Autowired
private MockMvc mockMvc;
// tests
}| Pattern | Context Loaded | Startup Time | Memory Usage | Verdict |
|---|---|---|---|---|
| @SpringBootTest with @AutoConfigureMockMvc | Full app context | 1-3 seconds | High | [X] Bad |
| @WebMvcTest for controller only | Web layer only | 0.2-0.6 seconds | Low | [OK] Good |