java-unit-test SKILL.md skillA

java-unit-test from baixuanzhu/skills is an agent skill: a SKILL.md folder an AI agent loads when a task calls for it.

Install it, pinned
mdr add baixuanzhu/skills/java-unit-test@v1.3.2

Pins v1.3.2 in mdr.lock. Pin the fingerprint instead.

Audit grade
A, 17 of 17 checks passed
Kind
SKILL.md skill
Repository
baixuanzhu/skills
Path
eval/java-unit-test/darwin-validation-v1.4.0/snapshots/versionB/SKILL.md
Versions recorded
1
Latest version
v1.3.2, committed Aug 3, 2026
Size
12,619 bytes
Repository stars
3
License
MIT

Java 单元测试**规范对齐**助手。在编写、评审、补全单元测试时使用本技能—— 无论用户是否提到具体框架(unit test / JUnit / Mockito / 测试用例 / 怎么测 / 测哪些 / 写多少测试)。 核心:统一团队的测试规范——用同一套设计方法(等价类/边界值/决策表/状态迁移)、 同一套默认(JUnit 5 原生断言、四维度必检)、同一套"写多少"的停止标准, 让不同人/不同对话产出的测试质量一致、可溯源、可审计,而非每次碰运气。 覆盖:一个方法必测的四维度(正向/反向/边界/异常)、最小充分集、 覆盖率反向校验、测试命名与组织、Mock 边界、"写多少"的成本收益判定。 次级触发信号:只写 happy path、补测试不知道写几个、手写一堆重复 @Test、 多条件分支只测一两种、有状态对象只测正常流转、@MockBean 用于纯单测、 不确定测试该写到什么程度。 工具默认:断言默认用 JUnit 5 原生 Assertions,仅在 3+ 字段断言/集合内容断言时升级到 AssertJ; Spring Boot 项目走…

Collected from public GitHub. Every version is saved exactly as it was and never changes. Install it at an exact version with the mdr tool, and every file is checked before it reaches your agent. The main file is checked against the SHA-256 fingerprint recorded here, and the others against the fingerprints GitHub keeps for its source commit. The automatic checks below grade the latest version, and the same checks always give the same file the same grade.

What the file says

# Java 单元测试

面向团队的**单元测试规范对齐助手**:统一"测什么、测多少、怎么设计、用什么默认"。规范分两部分——**A. 设计方法**(等价类/边界值/决策表/状态迁移)保证测得全;**B. 工程默认值与纪律**(断言库/Mock 边界/停止标准)保证每次一样。每条规则含「✗ 错误设计 → ✓ 正确设计」。

## 三条铁律

1. **设计优先于编码**:先确定"测哪些用例"(等价类/边界值/决策表/状态),再落成 `@Test`。禁止上来就写代码、想到哪测到哪——那是"覆盖率的幻觉",不是测试设计。
2. **最小充分集**:用等价类合并代表"无穷输入",用边界值钉住 off-by-one 高发区;**穷尽测试不可能**,目标是"用最少的用例覆盖最有代表性的输入"。一个方法的有效用例通常在 3~8 个之间,不是越多越好。
3. **栈中立**:测试框架**跟随项目既有**——JUnit 4 还是 5、Spring Boot 还是非 Spring,按项目现状走,不强加、不主动迁移。断言库默认见下方"断言库策略"。

## 断言库策略

**默认用 JUnit 原生 `Assertions`(`assertEquals`/`assertThrows`/`assertTrue` 等)。仅当满足以下任一条件时,升级到 AssertJ:**

- **同一对象需要 3 个及以上字段断言** —— AssertJ 的 `extracting(...).containsExactly(...)` 集中描述。
- **集合内容断言**(断言元素构成/顺序/提取字段)—— AssertJ 的 `containsExactlyInAnyOrder` / `extracting(...)`。

**其余场景(简单值、抛异常、1~2 个字段断言)一律 JUnit 原生,不切换。升级标准可机械执行:数字段数 / 判断是否集合。**

- Spring 项目 `spring-boot-starter-test` 已传递 AssertJ,触发阈值时直接用;非 Spring 项目首次触发时按 `references/06` §1 引入 `assertj-core`。
- 既有代码已用 AssertJ 的不主动改写;新测试默认 JUnit 原生,触发阈值时该测试用 AssertJ,同文件内可混用。

## 快速入门(第一次用,按这条线走)

| 你想做的 | 看这份 | 读多少 |
|---|---|---|
| 不知道测什么 / 测多少 | `references/01` 四维度 + `references/05` 三停止信号 | 各前 30 行 |
| 写纯计算/校验方法测试 | `references/02` | 通读(有完整范例) |
…

Read the whole file at its exact version.

How to install

The exact contents, by fingerprint
mdr add baixuanzhu/skills/java-unit-test@sha256:0fe96da748a81ed9

The line at the top of this page pins the label v1.3.2, which is what most people want. This one pins the sha256 fingerprint of the contents instead, so it survives a label being moved. Either way the exact version is written to mdr.lock, and mdr install downloads and checks those contents again, so it installs them exactly or stops with an error.

Badge

mdr badge

[![mdr](https://markdownregistry.com/badge/art_44ujsl5zdjr7yirn.svg)](https://markdownregistry.com/a/art_44ujsl5zdjr7yirn)

5 badge image fetches in 30 days. What the badge shows.

Versions

The registry has recorded 1 version of this file, committed on Aug 3, 2026.

versioncommittedcommitsizeaudit
v1.3.2 latest2026-08-03 aacb7cf 12,619 BA view

Audit of the latest version

A  17 of 17 checks passed. Fixed automatic checks with no AI involved, so the same checks give the same answer every run.
  • pass: Frontmatter block present
  • pass: Frontmatter declares a name
  • pass: Frontmatter declares a description
  • pass: Size between 200 bytes and 200 KB (12619 bytes)
  • pass: No zero-width or bidi control characters
  • pass: No instruction hidden inside an HTML comment
  • pass: No link to an exfiltration or paste host
  • pass: No credential-shaped string
  • pass: No instruction to send local credentials anywhere
  • pass: No text hidden with inline styles
  • pass: No prompt-injection phrasing
  • pass: No curl or wget piped into a shell
  • pass: No recursive delete of root, home or parent
  • pass: No instruction to read or print local credentials
  • pass: No base64 blob over 200 characters
  • pass: No link to a raw IP address
  • pass: No script tag

Source

GitHub

baixuanzhu/skills · 3 stars · license MIT · pushed 2026-11-03 · branch main

API

GET https://markdownregistry.com/api/v1/artifacts/art_44ujsl5zdjr7yirn
GET https://markdownregistry.com/api/v1/resolve?ref=baixuanzhu/skills/java-unit-test
GET https://markdownregistry.com/api/v1/blob/0fe96da748a81ed99657961b69d17eeaa3e4e2b08018a2a314ae3822ce9a78eb

Your AI assistant does the legwork. You hear about the deals worth your word. Hand yours the standing instructions at modelranch.com and it joins the network that reads files like this one.

Guides: the SKILL.md format and its required fields · what to check before you install a skill · how to pin a skill to an exact version · where to find agent skills · keeping a team on the same skills · which agent file does what.

More from baixuanzhu/skills

AGENTS.md AGENTS.md file
baixuanzhu/skills · AGENTS.md
git:20261027.6a2cc9a · audit A · 3 stars
CLAUDE.md CLAUDE.md file
baixuanzhu/skills · CLAUDE.md
git:20260822.070edce · audit B · 3 stars
java-coding-guide-pro SKILL.md skill
baixuanzhu/skills · eval/java-coding-guide-pro/darwin-validation-v3.4.0/snapshots/v3.3.0/SKILL.md · Java 编码规范与避坑助手。在编写、修改、重构或审查任何 Java / Spring Boot 代码时使用本技能—— 无论用户是否提到编码规范或具体工具库(Java coding / code review / refactoring…
v3.3.0 · audit A · 3 stars
java-coding-guide-pro SKILL.md skill
baixuanzhu/skills · eval/java-coding-guide-pro/darwin-validation-v3.4.0/snapshots/v3.4.0/SKILL.md · Java 编码规范与避坑助手。在编写、修改、重构或审查任何 Java / Spring Boot 代码时使用本技能—— 无论用户是否提到编码规范或具体工具库(Java coding / code review / refactoring…
v3.4.0 · audit A · 3 stars
java-coding-guide-pro SKILL.md skill
baixuanzhu/skills · eval/java-coding-guide-pro/darwin-validation-v3.4.0/snapshots/version1/SKILL.md · Java 编码规范与避坑助手。在编写、修改、重构或审查任何 Java / Spring Boot 代码时使用本技能—— 无论用户是否提到编码规范或具体工具库(Java coding / code review / refactoring…
v3.3.0 · audit A · 3 stars
java-coding-guide-pro SKILL.md skill
baixuanzhu/skills · eval/java-coding-guide-pro/darwin-validation-v3.4.0/snapshots/version2/SKILL.md · Java 编码规范与避坑助手。在编写、修改、重构或审查任何 Java / Spring Boot 代码时使用本技能—— 无论用户是否提到编码规范或具体工具库(Java coding / code review / refactoring…
v3.4.0 · audit A · 3 stars
java-coding-guide-pro SKILL.md skill
baixuanzhu/skills · eval/java-coding-guide-pro/darwin-validation-v3.4.0/snapshots/versionA/SKILL.md · Java 编码规范与避坑助手。在编写、修改、重构或审查任何 Java / Spring Boot 代码时使用本技能—— 无论用户是否提到编码规范或具体工具库(Java coding / code review / refactoring…
v3.4.0 · audit A · 3 stars
java-coding-guide-pro SKILL.md skill
baixuanzhu/skills · eval/java-coding-guide-pro/darwin-validation-v3.4.0/snapshots/versionB/SKILL.md · Java 编码规范与避坑助手。在编写、修改、重构或审查任何 Java / Spring Boot 代码时使用本技能—— 无论用户是否提到编码规范或具体工具库(Java coding / code review / refactoring…
v3.3.0 · audit A · 3 stars
java-coding-guide-pro SKILL.md skill
baixuanzhu/skills · eval/java-coding-guide-pro/darwin-validation-v3.5.0/snapshots/v3.4.1/SKILL.md · Java 编码规范与避坑助手。在编写、修改、重构或审查任何 Java / Spring Boot 代码时使用本技能—— 无论用户是否提到编码规范或具体工具库(Java coding / code review / refactoring…
v3.4.1 · audit A · 3 stars
java-coding-guide-pro SKILL.md skill
baixuanzhu/skills · eval/java-coding-guide-pro/darwin-validation-v3.5.0/snapshots/v3.5.0/SKILL.md · Java 编码规范与避坑助手。在编写、修改、重构或审查任何 Java / Spring Boot 代码时使用本技能—— 无论用户是否提到编码规范或具体工具库(Java coding / code review / refactoring…
v3.5.0 · audit A · 3 stars
java-coding-guide-pro SKILL.md skill
baixuanzhu/skills · eval/java-coding-guide-pro/darwin-validation-v3.5.0/snapshots/version1/SKILL.md · Java 编码规范与避坑助手。在编写、修改、重构或审查任何 Java / Spring Boot 代码时使用本技能—— 无论用户是否提到编码规范或具体工具库(Java coding / code review / refactoring…
v3.4.1 · audit A · 3 stars
java-coding-guide-pro SKILL.md skill
baixuanzhu/skills · eval/java-coding-guide-pro/darwin-validation-v3.5.0/snapshots/version2/SKILL.md · Java 编码规范与避坑助手。在编写、修改、重构或审查任何 Java / Spring Boot 代码时使用本技能—— 无论用户是否提到编码规范或具体工具库(Java coding / code review / refactoring…
v3.5.0 · audit A · 3 stars

Every file in baixuanzhu/skills

Other files named java-unit-test

java-unit-test SKILL.md skill
hashgraph-online/awesome-codex-plugins · plugins/Colin4k1024/tsp/skills/java-unit-test/SKILL.md · 为 Spring Boot 项目生成高质量 Java 单元测试代码。当用户要求"写单元测试"、"生成测试用例"、"帮我写 test"、"补充测试覆盖"、"写 JUnit 测试"、"写 Mockito 测试"、"测试这个 Service /…
git:20260512.6523792 · audit A · 1,537 stars
java-unit-test SKILL.md skill
baixuanzhu/skills · eval/java-unit-test/regression-v1.5.0/snapshots/version2/SKILL.md · Java 单元测试助手。在编写、评审、补全、重构单元测试时使用本技能—— 无论用户是否提到具体框架(unit test / JUnit / Mockito / 测试用例 / 怎么测 / 测哪些 / 写多少)。 次级触发信号——代码或…
v1.5.0 · audit A · 3 stars
java-unit-test SKILL.md skill
baixuanzhu/skills · eval/java-test/darwin-validation-v2.0.0/snapshots/blind/unit-B/versionA/SKILL.md · Java 开发期测试(纯单元测试)助手——@Mock + @InjectMocks,毫秒级,不起 Spring Context、不起容器、零测试基础设施。在编写、评审、补全、重构单元 测试时使用本技能,无论用户是否提到具体框架(unit…
v2.0.0 · audit A · 3 stars
java-unit-test SKILL.md skill
baixuanzhu/skills · eval/java-unit-test/darwin-validation-v1.4.0/snapshots/v1.3.2/SKILL.md · Java 单元测试**规范对齐**助手。在编写、评审、补全单元测试时使用本技能—— 无论用户是否提到具体框架(unit test / JUnit / Mockito / 测试用例 / 怎么测 / 测哪些 / 写多少测试)。…
v1.3.2 · audit A · 3 stars
java-unit-test SKILL.md skill
baixuanzhu/skills · eval/java-test/darwin-validation-v2.0.0/snapshots/v1-online-unit/SKILL.md · Java 单元测试助手。在编写、评审、补全、重构单元测试时使用本技能—— 无论用户是否提到具体框架(unit test / JUnit / Mockito / 测试用例 / 怎么测 / 测哪些 / 写多少)。 次级触发信号——代码或…
v1.5.3 · audit A · 3 stars
java-unit-test SKILL.md skill
baixuanzhu/skills · eval/java-test/darwin-validation-v2.0.0/snapshots/blind/unit-A/version2/SKILL.md · Java 开发期测试(纯单元测试)助手——@Mock + @InjectMocks,毫秒级,不起 Spring Context、不起容器、零测试基础设施。在编写、评审、补全、重构单元 测试时使用本技能,无论用户是否提到具体框架(unit…
v2.0.0 · audit A · 3 stars
java-unit-test SKILL.md skill
baixuanzhu/skills · eval/java-unit-test/darwin-validation-v1.4.0/snapshots/version1/SKILL.md · Java 单元测试**规范对齐**助手。在编写、评审、补全单元测试时使用本技能—— 无论用户是否提到具体框架(unit test / JUnit / Mockito / 测试用例 / 怎么测 / 测哪些 / 写多少测试)。…
v1.3.2 · audit A · 3 stars
java-unit-test SKILL.md skill
baixuanzhu/skills · skills/java-unit-test/SKILL.md · Java 开发期测试(纯单元测试)助手——@Mock + @InjectMocks 或项目既有的 @TestConfiguration 轻量 mock 装配,AssertJ 断言,毫秒级,零外部基础设施 (不连真实 DB / 容器 /…
v2.2.0 · audit A · 3 stars

Browse by kind, by grade A, or by owner.