How do you test the service layer in Spring Boot: when do you write a unit test with Mockito, and when do you bring up the application context?
~4 min by voice
How to approach it
This checks whether the candidate can pick the test level for the job: fast Mockito unit tests for business logic, context slices and Testcontainers for integration, full @SpringBootTest only selectively. It also gauges their understanding of a test's cost: speed, brittleness and context caching.
The interviewer will ask this question and listen. Think out loud and ask for a hint if you need one. When you're done, pause or tap “That's my answer”. In about a minute, your score and the points you covered show up here.