java-unit-test-expert

Community

Produce maintainable, runnable Java unit tests

AuthorXunzi229
Version1.0.0
Installs0

System Documentation

What problem does it solve?

This skill eliminates low-quality, non-repeatable, or incomplete Java unit tests by providing strict, actionable rules and ready-to-run JUnit 5 + Mockito test implementations that improve maintainability and coverage for Spring Boot codebases.

Core Features & Use Cases

  • Strict mocking and isolation: mock only dependencies of the system under test; never mock the SUT methods or DTO/POJO objects; use @WebMvcTest for controllers and Mockito extensions for other layers.
  • Robust assertions and patterns: unify numeric comparisons to avoid overload ambiguity, use ReflectionTestUtils for private field injection when necessary, and require @DisplayName on each test method.
  • Coverage-driven test design: produce normal, error, and boundary cases for each non-static, non-private method with the goal of >80% line coverage and include all necessary imports and annotations so tests are self-contained and runnable.
  • Typical use cases: adding controller/service tests for Spring Boot 2.1.x, improving flaky or incomplete tests, creating regression tests after refactors or bug fixes, and reviewing/enforcing test quality and conventions.

Quick Start

Generate JUnit 5 tests for the UserService in a Spring Boot 2.1.x project that mock only its dependencies, cover normal, exception, and boundary scenarios, and include all imports and annotations so the tests run immediately.

Dependency Matrix

Required Modules

None required

Components

Standard package

💻 Claude Code Installation

Recommended: Let Claude install automatically. Simply copy and paste the text below to Claude Code.

Please help me install this Skill:
Name: java-unit-test-expert
Download link: https://github.com/Xunzi229/skills/archive/main.zip#java-unit-test-expert

Please download this .zip file, extract it, and install it in the .claude/skills/ directory.
View Source Repository

Agent Skills Search Helper

Install a tiny helper to your Agent, search and equip skill from 471,000+ vetted skills library on demand.