Skip to content
Sharp

Testing · interview question

In a Spring Boot application, which annotation is used to limit the test scope to only the controller layer?

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

Correct answer

A. @WebMvcTest

Why

@WebMvcTest is used to create application context configurations that focus only on the web layer, allowing you to test Spring MVC controllers in isolation without loading the full application context.

Test yourself on Testing

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

Start free test
All Testing questions →