
Unit Test Controller Layer
This generates unit tests for Spring REST controllers using MockMvc and standalone setup, keeping your tests isolated from the full application context. You get patterns for all the HTTP methods, JsonPath assertions for response validation, and examples covering the annoying edge cases like validation errors, custom headers, and path variables. It mocks service dependencies with Mockito so you're only testing the controller layer's HTTP handling, not business logic. The validation workflow tip is handy: add andDo(print()) when tests fail to see what MockMvc actually returned. Watch out though, standaloneSetup skips some Spring magic like security annotations, so you might need integration tests for those scenarios anyway.
- skills.sh installs
- 3.9K
- GitHub stars
- 369
- last updated
- Aug 21, 2026
Install
$ npx -y skills add giuseppe-trisciuoglio/developer-kit --skill unit-test-controller-layer --agent claude-codeInstalls into .claude/skills of the current project.
Files
Unit Testing REST Controllers with MockMvc
Overview
Provides patterns for unit testing @RestController and @Controller classes using MockMvc. Covers request/response handling, HTTP status codes, request parameter binding, validation, content negotiation, response headers, and exception handling with mocked service dependencies.
When to Use
Use for: controller tests, API endpoint testing, Spring MVC tests, mock HTTP requests, unit testing web layer endpoints, verifying REST controllers in isolation.
Instructions
Sponsors
Details
- Repository
- github.com/giuseppe-trisciuoglio/developer-kit
- Categories
- Backend & APIs, Testing & QA, Debugging, Java & JVM
- First seen
- May 16, 2026
More from giuseppe-trisciuoglio/developer-kit
All 102- Unit Test Parameterized3.9K
- Unit Test Json Serialization3.9K
- Spring Boot Saga Pattern3.9K
- Spring Data Neo4j3.9K
- Unit Test Security Authorization3.9K
- Nextjs Data Fetching3.9K
- Langchain4j Tool Function Calling Patterns3.9K
- Nx Monorepo3.9K
- Langchain4j Spring Boot Integration3.9K
- Langchain4j Rag Implementation Patterns3.9K
- Unit Test Scheduled Async3.9K
- Rag3.9K
- Unit Test Utility Methods3.9K
- Qdrant3.9K
- Unit Test Exception Handler3.9K
- Unit Test Mapper Converter3.9K
- Langchain4j Ai Services Patterns3.9K
- Unit Test Caching3.8K
- Unit Test Config Properties3.8K
- Unit Test Application Events3.8K
- Langchain4j Vector Stores Configuration3.8K
- Langchain4j Mcp Server Patterns3.8K
- Aws Sdk Java V2 S33.8K
- Langchain4j Testing Strategies3.8K