unit-tests

Generates JUnit 5 and Mockito unit tests covering happy paths, exceptions, and edge cases for Spring Boot classes.

Updated Jun 25, 2026
One-click install
npx skills add https://github.com/oriddd/ai-toolkit --skill unit-tests-oriddd
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: unit-tests
Source: https://github.com/oriddd/ai-toolkit/tree/main/copilot/public/skills/unit-tests
Command: npx skills add https://github.com/oriddd/ai-toolkit --skill unit-tests-oriddd

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Writing meaningful unit tests is time-consuming, and teams often end up with coverage-padding tests that execute code without verifying behavior. This Skill generates high-coverage JUnit 5 + Mockito tests for Spring Boot classes that exercise happy paths, every exception branch, and boundary conditions — not just line coverage. ## Core Features & Use Cases - Branch-complete test generation: Enumerates collaborators, public methods, and every if/switch/exception branch to produce positive and negative tests per method, following the methodName_Condition_ExpectedResult naming convention. - Advanced testing techniques built in: Covers static mocking with MockedStatic, parameterized tests, AssertJ fluent assertions, test data builders, WireMock/MockWebServer for HTTP clients, jqwik property-based testing, ArchUnit architecture rules, and PIT mutation testing. - Use Case: After adding a new service class to src/main/java, invoke this Skill to generate a mirror-package test class, run it with Jacoco, and iterate until line and branch coverage thresholds are met with genuinely meaningful assertions. ## Quick Start Generate meaningful JUnit 5 and Mockito unit tests with full branch coverage for the class I just added under src/main/java.

Frequently Asked Questions about unit-tests

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I write unit tests for a Spring Boot service class with Mockito?

Use @ExtendWith(MockitoExtension.class) with @Mock for each constructor collaborator and @InjectMocks for the class under test. Constructor injection in src/main lets Mockito wire dependencies automatically, then stub with when(...).thenReturn(...) and verify interactions.

How to mock static methods in JUnit 5 tests?

Use Mockito's MockedStatic inside a try-with-resources block within the test method, never as a class field. This prevents the static stub from leaking between tests and breaking parallel execution.

AssertJ vs JUnit Assertions — which should I use for unit tests?

AssertJ is preferred for everything except the simplest assertEquals because it produces better failure messages and fluent chaining. Pick one library per repository and stay consistent; assertSoftly collects multiple failures in a single run.

Why is line coverage not enough for meaningful unit tests?

Line coverage measures execution, not verification — tests can run code without asserting on results. PIT mutation testing seeds bugs into your code and reports which mutants survive, revealing tests that exercise code but never verify behavior.

When should I not write a unit test for a class?

Skip tests for classes with no logic such as pure DTOs, records, or Lombok @Getter holders. Instead, add them to the jacoco-maven-plugin excludes list so they do not distort coverage metrics.

How do I unit test an HTTP client without a real server?

Stub the HTTP boundary with MockWebServer or WireMock, enqueue mock responses with specific bodies and status codes, then assert deserialization and verify that non-2xx responses translate into domain exceptions.