
Unit Test Exception Handler
Spring Boot unit-test patterns for @ExceptionHandler and @ControllerAdvice using standalone MockMvc setups.
- CCM score
- 51 of 100
- skills.sh installs
- 3.9K
- GitHub stars
- 372
- last updated
- Aug 21, 2026
Own this skill? Claim it
What it does
- Covers HTTP status assertions, JSON error payload checks, and field-level validation error verification for exception handlers
- Includes a test controller pattern that throws specific exceptions, plus a
GlobalExceptionHandlerexample withErrorResponseandValidationErrorResponserecords - Enforces a rule to register the advice with
setControllerAdvice()and to assert every field in the error body, not only the status - Designed for Spring Boot projects writing REST API error tests without loading the full application context
Install
$ npx -y skills add giuseppe-trisciuoglio/developer-kit --skill unit-test-exception-handler -yInstalls into .agents/skills for every agent it finds here, and .claude/skills for Claude Code.
Files
Unit Testing ExceptionHandler and ControllerAdvice
Overview
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.
When to Use
- Writing unit tests for
@ExceptionHandlermethods - Testing
@ControllerAdviceglobal exception handling - Validating REST API error response formatting
- Mocking exceptions in controller tests
- Testing field-level validation error responses
- Asserting custom error payloads and HTTP status codes
Instructions
Details
- Repository
- github.com/giuseppe-trisciuoglio/developer-kit
- Categories
- Testing & QA, Java & JVM
- First seen
- May 16, 2026
More from giuseppe-trisciuoglio/developer-kit
All 95- Unit Test Mapper Converter3.9K
- Langchain4j Ai Services Patterns3.9K
- Unit Test Caching3.9K
- Unit Test Config Properties3.9K
- Unit Test Application Events3.9K
- Langchain4j Vector Stores Configuration3.9K
- Langchain4j Mcp Server Patterns3.9K
- Aws Sdk Java V2 S33.9K
- Langchain4j Testing Strategies3.9K
- Aws Sdk Java V2 Dynamodb3.9K
- Aws Rds Spring Boot Integration3.9K
- Nextjs Deployment3.9K
- Aws Sdk Java V2 Lambda3.9K
- Aws Sdk Java V2 Core3.9K
- Aws Sdk Java V2 Bedrock3.9K
- Aws Sdk Java V2 Messaging3.9K
- Aws Sdk Java V2 Secrets Manager3.9K
- Aws Sdk Java V2 Kms3.9K
- Aws Sdk Java V2 Rds3.9K
- Nestjs Drizzle Crud Generator3.8K
- Aws Lambda Python Integration3.8K
- Aws Lambda Typescript Integration3.8K
- Sonarqube Mcp3.8K
- Better Auth3.8K
Similar to Unit Test Exception Handler
More Testing & QA
unit-test-controller-layergiuseppe-trisciuoglio/developer-kit4K installsPatterns for unit testing REST controllers with MockMvc, covering status codes, validation, and error handling.
spring-boot-rest-api-standardsgiuseppe-trisciuoglio/developer-kit4.4K installsREST API design standards for Spring Boot covering URLs, DTOs, validation, errors, pagination, and security headers.
spring-bootmindrally/skills877 installsExpert Spring Boot guidance covering REST APIs, testing, security, and deployment for Java 17+ projects.
springboot-tddaffaan-m/ecc6.2K installsTest-driven workflow for Spring Boot services using JUnit 5, Mockito, MockMvc, Testcontainers, and JaCoCo.
java-spring-bootpluginagentmarketplace/custom-plugin-java11.8K installsProduction Spring Boot guidance covering REST APIs, Spring Security, Spring Data JPA, and Actuator monitoring.
spring-boot-testinggithub/awesome-copilot2.1K installsExpert Spring Boot testing guide that picks the right test slice, Testcontainers setup, and mocking approach.