{"id":"51ec2b4d-8b25-4825-ab8f-ec795faf4ed9","shortId":"vUM3aF","kind":"skill","title":"321-frameworks-spring-boot-testing-unit-tests","tagline":"Use when you need to write unit tests for Spring Boot applications — including pure unit tests with @ExtendWith(MockitoExtension.class) for @Service/@Component, slice tests with @WebMvcTest and @MockitoBean for controllers, @JsonTest for JSON serialization, parameterized tests wi","description":"# Spring Boot Unit Testing with Mockito\n\nApply Spring Boot unit testing guidelines with Mockito.\n\n**What is covered in this Skill?**\n\n- Pure unit tests: @ExtendWith(MockitoExtension.class), @Mock, @InjectMocks for @Service/@Component (no Spring context)\n- Slice tests: @WebMvcTest, @MockitoBean for controllers (Spring Boot 4.0.x — @MockBean removed)\n- @JsonTest for JSON serialization with correct JSON value assertions (extractingJsonPathStringValue, etc.)\n- Parameterized tests: @ParameterizedTest with @CsvSource or @MethodSource over copy-pasted methods\n- Java records for domain objects in tests\n- @TestConfiguration, @ActiveProfiles, @Primary fixed-clock beans for deterministic test setup\n- Modern mocking API: @MockitoBean / @MockitoSpyBean; @MockBean/@SpyBean are deprecated/removed in Boot 4.0.x\n\n**Scope:** Apply recommendations based on the reference rules and good/bad code examples. For integration tests use @322-frameworks-spring-boot-testing-integration-tests.\n\n## Constraints\n\nBefore applying any test changes, ensure the project compiles. If compilation fails, stop immediately. After applying improvements, run full verification.\n\n- **MANDATORY**: Run `./mvnw compile` or `mvn compile` before applying any change\n- **SAFETY**: If compilation fails, stop immediately\n- **VERIFY**: Run `./mvnw clean verify` or `mvn clean verify` after applying improvements\n- **BEFORE APPLYING**: Read the reference for detailed rules and good/bad patterns\n- **EDGE CASE**: If request scope is ambiguous, stop and ask a clarifying question before applying changes\n- **EDGE CASE**: If required inputs, files, or tooling are missing, report what is missing and ask whether to proceed with setup guidance\n\n## When to use this skill\n\n- Review Java code for Spring Boot unit tests\n- Apply best practices for Spring Boot unit tests in Java code\n\n## Workflow\n\n1. **Read reference and assess project context**\n\nRead `references/321-frameworks-spring-boot-testing-unit-tests.md` and inspect the current project setup before proposing changes.\n\n2. **Gather scope and decide target improvements**\n\nIdentify requested outcomes, constraints, and the minimum safe set of changes to apply.\n\n3. **Apply framework-aligned changes**\n\nImplement or refactor configuration/code following the reference patterns and project conventions.\n\n4. **Run verification and report results**\n\nExecute appropriate build/tests and summarize what changed, what was verified, and any follow-up actions.\n\n## Reference\n\nFor detailed guidance, examples, and constraints, see [references/321-frameworks-spring-boot-testing-unit-tests.md](references/321-frameworks-spring-boot-testing-unit-tests.md).","tags":["321","frameworks","spring","boot","testing","unit","tests","cursor","rules","java","jabrena","agent-skills"],"capabilities":["skill","source-jabrena","skill-321-frameworks-spring-boot-testing-unit-tests","topic-agent-skills","topic-ai-skills","topic-claude","topic-claude-code","topic-claude-code-skills","topic-claude-code-subagents","topic-claude-skills","topic-cursor-agent","topic-cursor-ai","topic-cursor-skills","topic-cursorai","topic-github-copilot"],"categories":["cursor-rules-java"],"synonyms":[],"warnings":[],"endpointUrl":"https://skills.sh/jabrena/cursor-rules-java/321-frameworks-spring-boot-testing-unit-tests","protocol":"skill","transport":"skills-sh","auth":{"type":"none","details":{"cli":"npx skills add jabrena/cursor-rules-java","source_repo":"https://github.com/jabrena/cursor-rules-java","install_from":"skills.sh"}},"qualityScore":"0.631","qualityRationale":"deterministic score 0.63 from registry signals: · indexed on github topic:agent-skills · 362 github stars · SKILL.md body (2,661 chars)","verified":false,"liveness":"unknown","lastLivenessCheck":null,"agentReviews":{"count":0,"score_avg":null,"cost_usd_avg":null,"success_rate":null,"latency_p50_ms":null,"narrative_summary":null,"summary_updated_at":null},"enrichmentModel":"deterministic:skill-github:v1","enrichmentVersion":1,"enrichedAt":"2026-04-26T12:53:37.351Z","embedding":null,"createdAt":"2026-04-18T22:02:15.637Z","updatedAt":"2026-04-26T12:53:37.351Z","lastSeenAt":"2026-04-26T12:53:37.351Z","tsv":"'/mvnw':192,209 '1':293 '2':311 '3':331 '321':1 '322':161 '4':348 '4.0':87,143 'action':369 'activeprofil':122 'align':335 'ambigu':236 'api':134 'appli':52,146,171,185,198,217,220,244,281,330,332 'applic':20 'appropri':355 'ask':239,261 'assert':99 'assess':297 'base':148 'bean':127 'best':282 'boot':5,19,47,54,86,142,165,278,286 'build/tests':356 'case':231,247 'chang':174,200,245,310,328,336,360 'clarifi':241 'clean':210,214 'clock':126 'code':155,275,291 'compil':178,180,193,196,203 'compon':30,75 'configuration/code':340 'constraint':169,321,376 'context':78,299 'control':38,84 'convent':347 'copi':111 'copy-past':110 'correct':96 'cover':62 'csvsourc':106 'current':305 'decid':315 'deprecated/removed':140 'detail':225,372 'determinist':129 'domain':117 'edg':230,246 'ensur':175 'etc':101 'exampl':156,374 'execut':354 'extendwith':26,69 'extractingjsonpathstringvalu':100 'fail':181,204 'file':251 'fix':125 'fixed-clock':124 'follow':341,367 'follow-up':366 'framework':3,163,334 'framework-align':333 'frameworks-spring-boot-testing-integration-test':162 'frameworks-spring-boot-testing-unit-test':2 'full':188 'gather':312 'good/bad':154,228 'guidanc':267,373 'guidelin':57 'identifi':318 'immedi':183,206 'implement':337 'improv':186,218,317 'includ':21 'injectmock':72 'input':250 'inspect':303 'integr':158,167 'java':114,274,290 'json':41,93,97 'jsontest':39,91 'mandatori':190 'method':113 'methodsourc':108 'minimum':324 'miss':255,259 'mock':71,133 'mockbean':89,137 'mockito':51,59 'mockitobean':36,82,135 'mockitoextension.class':27,70 'mockitospybean':136 'modern':132 'mvn':195,213 'need':12 'object':118 'outcom':320 'parameter':43,102 'parameterizedtest':104 'past':112 'pattern':229,344 'practic':283 'primari':123 'proceed':264 'project':177,298,306,346 'propos':309 'pure':22,66 'question':242 'read':221,294,300 'recommend':147 'record':115 'refactor':339 'refer':151,223,295,343,370 'references/321-frameworks-spring-boot-testing-unit-tests.md':301,378,379 'remov':90 'report':256,352 'request':233,319 'requir':249 'result':353 'review':273 'rule':152,226 'run':187,191,208,349 'safe':325 'safeti':201 'scope':145,234,313 'see':377 'serial':42,94 'servic':29,74 'set':326 'setup':131,266,307 'skill':65,272 'skill-321-frameworks-spring-boot-testing-unit-tests' 'slice':31,79 'source-jabrena' 'spring':4,18,46,53,77,85,164,277,285 'spybean':138 'stop':182,205,237 'summar':358 'target':316 'test':6,8,16,24,32,44,49,56,68,80,103,120,130,159,166,168,173,280,288 'testconfigur':121 'tool':253 'topic-agent-skills' 'topic-ai-skills' 'topic-claude' 'topic-claude-code' 'topic-claude-code-skills' 'topic-claude-code-subagents' 'topic-claude-skills' 'topic-cursor-agent' 'topic-cursor-ai' 'topic-cursor-skills' 'topic-cursorai' 'topic-github-copilot' 'unit':7,15,23,48,55,67,279,287 'use':9,160,270 'valu':98 'verif':189,350 'verifi':207,211,215,363 'webmvctest':34,81 'whether':262 'wi':45 'workflow':292 'write':14 'x':88,144","prices":[{"id":"fbfc4106-027b-4335-b06b-0c4b270d7524","listingId":"51ec2b4d-8b25-4825-ab8f-ec795faf4ed9","amountUsd":"0","unit":"free","nativeCurrency":null,"nativeAmount":null,"chain":null,"payTo":null,"paymentMethod":"skill-free","isPrimary":true,"details":{"org":"jabrena","category":"cursor-rules-java","install_from":"skills.sh"},"createdAt":"2026-04-18T22:02:15.637Z"}],"sources":[{"listingId":"51ec2b4d-8b25-4825-ab8f-ec795faf4ed9","source":"github","sourceId":"jabrena/cursor-rules-java/321-frameworks-spring-boot-testing-unit-tests","sourceUrl":"https://github.com/jabrena/cursor-rules-java/tree/main/skills/321-frameworks-spring-boot-testing-unit-tests","isPrimary":false,"firstSeenAt":"2026-04-18T22:02:15.637Z","lastSeenAt":"2026-04-26T12:53:37.351Z"}],"details":{"listingId":"51ec2b4d-8b25-4825-ab8f-ec795faf4ed9","quickStartSnippet":null,"exampleRequest":null,"exampleResponse":null,"schema":null,"openapiUrl":null,"agentsTxtUrl":null,"citations":[],"useCases":[],"bestFor":[],"notFor":[],"kindDetails":{"org":"jabrena","slug":"321-frameworks-spring-boot-testing-unit-tests","github":{"repo":"jabrena/cursor-rules-java","stars":362,"topics":["agent-skills","ai-skills","claude","claude-code","claude-code-skills","claude-code-subagents","claude-skills","cursor-agent","cursor-ai","cursor-skills","cursorai","github-copilot","intellij-idea","java","prompting","system-prompts"],"license":"apache-2.0","html_url":"https://github.com/jabrena/cursor-rules-java","pushed_at":"2026-04-26T12:50:01Z","description":"A curated and opinionated collection of Skills and Agents to be used in modern SDLC workflows for Java Enterprise development with your favorite AI Agent harness.","skill_md_sha":"69111cec4ad07c837e4499f9f3b04e7cc3f54279","skill_md_path":"skills/321-frameworks-spring-boot-testing-unit-tests/SKILL.md","default_branch":"main","skill_tree_url":"https://github.com/jabrena/cursor-rules-java/tree/main/skills/321-frameworks-spring-boot-testing-unit-tests"},"layout":"multi","source":"github","category":"cursor-rules-java","frontmatter":{"name":"321-frameworks-spring-boot-testing-unit-tests","license":"Apache-2.0","description":"Use when you need to write unit tests for Spring Boot applications — including pure unit tests with @ExtendWith(MockitoExtension.class) for @Service/@Component, slice tests with @WebMvcTest and @MockitoBean for controllers, @JsonTest for JSON serialization, parameterized tests with @CsvSource/@MethodSource, test profiles, and @TestConfiguration. For framework-agnostic Java use @131-java-testing-unit-testing. For integration tests use @322-frameworks-spring-boot-testing-integration-tests. This should trigger for requests such as Review Java code for Spring Boot unit tests; Apply best practices for Spring Boot unit tests in Java code. Part of cursor-rules-java project"},"skills_sh_url":"https://skills.sh/jabrena/cursor-rules-java/321-frameworks-spring-boot-testing-unit-tests"},"updatedAt":"2026-04-26T12:53:37.351Z"}}