test-unit

Generate unit tests, test cases, and mocks from source code.

1|Updated Dec 22, 2025
One-click install
npx skills add https://github.com/Harries/hydpromptkit --skill test-unit-harries
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: test-unit
Source: https://github.com/Harries/hydpromptkit/tree/main/skills/test-unit
Command: npx skills add https://github.com/Harries/hydpromptkit --skill test-unit-harries

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

单元测试代码生成工具帮助开发者快速为待测代码生成高质量的单元测试、测试用例和 Mock 对象,提升测试覆盖率与代码质量。

Core Features & Use Cases

  • 自动生成单元测试代码、测试用例与 Mock 对象,支持 Service、Controller、Mapper 等常见层级。
  • 支持基于设计文档与源码的测试需求分段生成,提供模板化测试结构与断言模板。
  • 提供完整的测试框架集成示例(JUnit5、Mockito、AssertJ),以及分阶段生成策略以适应大型项目。

Quick Start

给定待测代码和可选的设计文档路径,输入测试需求后,自动生成对应的单元测试代码并提供完整的测试模板。

Frequently Asked Questions about test-unit

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

FAQPage Schema
How do I generate unit tests and mocks from source code automatically?

To generate unit tests and mocks from source code, provide the code path and optional design documents. The tool analyzes the input to produce test cases and mock objects for service, controller, and mapper layers.

Can I generate JUnit5 test cases with Mockito and AssertJ for a large project?

Yes, you can generate JUnit5 test cases with Mockito and AssertJ for large projects. It applies a segmented generation strategy using flags like --class, --method, --layer, --module, and --scenario to handle scale efficiently.

What is the best way to create test cases for different application layers like Service and Controller?

The best way to create test cases for Service, Controller, and Mapper layers is using the --layer segmentation option. This targets the specific module architecture to output structured test templates and mocks.

Does generating test cases from source code require a design document?

Generating test cases from source code does not strictly require a design document. You can input just the source code path, but providing a design document enhances test coverage by integrating deeper contextual requirements.

How do I generate unit tests for a single method instead of an entire class?

To generate unit tests for a single method, use the --method segmentation option. This isolates the test generation scope to the specific method level, producing focused test cases and targeted mocks.

Why use AssertJ and Mockito assertions when generating test cases?

Using AssertJ and Mockito when generating test cases ensures framework compatibility and fluent assertions. This integration produces complete, runnable test templates that validate complex behaviors and mock dependencies effectively.