MockMvc Testing — Concept Check
Questions on MockMvc Testing. MockMvc dispatches requests through the MVC pipeline without starting a real server, enabling fast controller tests with request/response assertions.
Questions in this quiz
7 questions on MockMvc Testing — Concept Check. Work through them here, then start the quiz to answer them and see your score.
1.You are testing a Spring controller using MockMvc. Which setup provides the fastest test execution?
- AStandalone MockMvc with real beans
- B@SpringBootTest with real server
- C@AutoConfigureMockMvc with full Spring context
- DStandalone MockMvc setup with Mockito
2.A developer uses MockMvc to test a controller method. They notice the test is slow. What could be a reason?
- ARunning tests in parallel
- BUsing @SpringBootTest with real server
- CUsing MockMvcBuilders.standaloneSetup()
- DMocking dependencies with Mockito
3.When using MockMvc, which method allows you to verify HTTP status codes in the response?
- AsetControllerAdvice()
- BmockMvc.perform()
- Cperform(get("/api/orders"))
- DandExpect(status().isOk())
4.A developer wants to test a controller with security filters. Which setup should they use?
- AMockMvc with Mockito only
- BMockMvcBuilders.standaloneSetup()
- CStandalone setup with real beans
- D@AutoConfigureMockMvc with @SpringBootTest
5.A test using MockMvc fails because it can't find a real network port. What is likely the issue?
- AStandalone setup needs network configuration
- BMockMvc requires a real network port
- C@SpringBootTest is missing
- DThe test is incorrectly set up to use a real server
6.A test using MockMvc's multipart() method fails. What might be the reason?
- AMultipart requests need real server
- BMockMvc doesn't support file uploads
- CIncorrect file path
- DMissing MockMultipartFile setup
7.What is the primary advantage of using MockMvc over @SpringBootTest with a real server?
- ABetter for production
- BFaster test execution
- CMore accurate results
- DEasier to configure