Bird
0
0

Given the following test snippet, what HTTP status code will be asserted?

medium📝 component behavior Q13 of 15
Spring Boot - Testing Spring Boot Applications
Given the following test snippet, what HTTP status code will be asserted?
mockMvc.perform(get("/hello"))
       .andExpect(status().isOk());
A404 Not Found
B500 Internal Server Error
C200 OK
D302 Redirect
Step-by-Step Solution
Solution:
  1. Step 1: Understand status().isOk()

    The method status().isOk() checks for HTTP status code 200.
  2. Step 2: Match status codes

    200 means success, 404 means not found, 500 means server error, 302 means redirect.
  3. Final Answer:

    200 OK -> Option C
  4. Quick Check:

    status().isOk() = 200 OK [OK]
Quick Trick: isOk() always means HTTP 200 success [OK]
Common Mistakes:
  • Confusing isOk() with error codes
  • Assuming isOk() means redirect
  • Mixing status codes meanings

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Spring Boot Quizzes