Provides patterns for unit testing REST controllers using MockMvc and @WebMvcTest. Generates controller tests that validates request/response mapping, validation, exception handling, and HTTP status codes.
SkillScore91Maintained
Automatic
◆QA & Test Engineering pack
Last verified 8/21/2026
What it changes
Passed 20 of 22 test cases with the skill, and 18 of 22 without it.
Without skill82%
With skill91%
Checks it passed that the model alone missed
Uses MockMvcBuilders.standaloneSetup to initialize MockMvc.
Uses @ExtendWith(MockitoExtension.class) on the test class.
Uses @Mock and @InjectMocks annotations for dependency injection.
and 1 more in the full report
2 fixed18 passed either way2 still failing0 broke
Pass-rate lift
+9 pp
Tokens
+75%
Agent turns
0%
Response time
-21%
Model gemini-3.6-flashMeasured 8/21/2026v120 of 22 cases passed with skill
Tokens, turns and time describe resource use, not a dollar price.
See it in action
One of 2 test cases the skill fixed. Same model, same prompt, with and without the skill.
1 of 2
Prompt
I have a Spring Boot OrderController that calls an OrderService to create orders (POST /api/orders) and fetch orders by ID (GET /api/orders/{id}). Can you write a JUnit 5 unit test class that tests these endpoints in isolation, verifying that creating an order returns 201 with the created JSON body and fetching a non-existent order handles missing resources cleanly?
What was checked, without and with the skill
Checked
Without skill
With skill
Uses MockMvcBuilders.standaloneSetup to initialize MockMvc.
Missed
Passed
Uses @Mock and @InjectMocks annotations for dependency injection.
Missed
Passed
case-01 · gemini-3.6-flash · 8/21/2026 · answers are capped and redacted
What's inside
The instructions your model reads when the skill loads.
SKILL.md241 lines4 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
Setup standalone MockMvc: MockMvcBuilders.standaloneSetup(controller) for isolated testing
Mock service dependencies: Use @Mock for all services, @InjectMocks for the controller
Test HTTP methods: GET, POST, PUT, PATCH, DELETE with correct status codes
Validate responses: JsonPath assertions for JSON, content matchers for body
Test validation: Send invalid input, verify 400 status with error details
Test errors: Verify 404, 400, 401, 403, 500 for appropriate conditions
Validate headers: Both request (Authorization) and response headers
Test content negotiation: Different Accept and Content-Type headers
Validation Workflow
Run test → If fails: add .andDo(print()) → Check actual vs expected → Fix assertion