Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Guides unit testing of Spring Boot ExceptionHandler and ControllerAdvice classes using MockMvc.
95% 100%+5 ptsof test cases passed
Passed 22 of 22 test cases with the skill, and 21 of 22 without it.
Its SkillScore uses its best run instead: +9 pts on gemini-3.6-flash, Aug 21, 2026.
3 of 3 safety checks passed
598 agent runs
7 forksA fork is a copy of this skill that someone made so they could edit it for their own use. The original doesn't change.
This skill provides patterns for writing unit tests for Spring Boot exception handlers. It covers testing @ExceptionHandler methods in @ControllerAdvice classes using MockMvc, including HTTP status assertions, JSON response validation, field-level validation error testing, and mocking handler dependencies.
@ExceptionHandler methods@ControllerAdvice global exception handling@ExceptionHandlersetControllerAdvice() on MockMvcBuilders.standaloneSetup().andExpect(status().isXxx())jsonPath("$.field") matchersMethodArgumentNotValidException produces field-level details.andDo(print()) — if handler not invoked, verify setControllerAdvice() is called and exception type matches@ControllerAdvice
public class GlobalExceptionHandler {
@ExceptionHandler(ResourceNotFoundException.class)
@ResponseStatus(HttpStatus.NOT_FOUND)
public ErrorResponse handleNotFound(ResourceNotFoundException ex) {
return new ErrorResponse(404, "Not Found", ex.getMessage());
}
@ExceptionHandler(ValidationException.class)
@ResponseStatus(HttpStatus.BAD_REQUEST)
Skills that do similar work, with their benchmark result.
Next to this one in the catalogue, plus more from the same author.