test-gen

Generate JUnit 5 and Mockito test classes for Java Service layer methods.

1|Updated Jan 26, 2026
One-click install
npx skills add https://github.com/xmx0632/claude-code-demo --skill test-gen-xmx0632
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: test-gen
Source: https://github.com/xmx0632/claude-code-demo/tree/main/Skills-Collection/test-gen
Command: npx skills add https://github.com/xmx0632/claude-code-demo --skill test-gen-xmx0632

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

为 Java Service 层方法自动生成 JUnit + Mockito 测试用例,显著降低手工编写测试的时间成本并提升测试覆盖率。

Core Features & Use Cases

  • 自动识别 Service 方法并生成测试骨架、Mock 和测试数据
  • 自动编写断言语句,覆盖正常、边界与异常场景
  • 兼容事务性测试和隔离测试,支持简单的 Spring 测试环境

Quick Start

使用 Service 类名作为输入,一次性生成对应的单元测试代码并放置在 src/test/java 目录下。

Frequently Asked Questions about test-gen

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

FAQPage Schema
How do I auto-generate JUnit 5 unit tests for Java service layer methods?

To auto-generate JUnit 5 unit tests for Java service layer methods, provide a Service class name as input. The tool outputs test classes with Mockito mocks and assertions into the src/test/java directory.

Can I automatically mock mappers and repositories when generating Spring Boot unit tests?

Yes, you can automatically mock mappers and repositories when generating Spring Boot unit tests. The tool creates mocked dependencies for Service/Mapper interactions, allowing isolated testing without a live database connection.

Does this tool generate test data and assertions covering boundary and exceptional cases?

Yes, this tool generates test data and assertions covering boundary and exceptional cases. It automatically writes assertion statements for normal flows, edge values, and exception scenarios to improve test coverage.

What is the best way to create Mockito test skeletons for existing Java Service classes?

The best way to create Mockito test skeletons for existing Java Service classes is submitting the class name directly. It instantly produces structured test code with predefined mocks, test data, and assertions under src/test/java.

Do I need a specific Spring Boot project structure to generate Java unit tests?

You need a typical Spring Boot style project structure to generate Java unit tests. The tool expects standard Service/Mapper interaction patterns to correctly map dependencies and place output files in src/test/java.