Skip to content
Sharp

Testing · interview question

When using MockMvc to test a controller, which method would you use to simulate an HTTP GET request?

Multiple choiceMediumchapter-10-curatedpremiumtestingcontroller-testing
Choose one answer
Answer and explanation

Correct answer

A. MockMvc.perform(get("/path"))

Why

The perform method combined with the get method is used in Spring's MockMvc to simulate HTTP GET requests, allowing developers to test how a controller handles specific endpoints.

Test yourself on Testing

A free test with instant, explained results. No account needed.

Start free test
All Testing questions →