java-unit-test SKILL.md skillA

This file is byte-identical to the first copy the registry indexed, one of 3 indexed copies. Same content hash, so the same checks give both the same grade.

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.5.3

Pins v1.5.3 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-test/darwin-validation-v2.0.0/snapshots/blind/unit-A/version1/SKILL.md
Versions recorded
1
Latest version
v1.5.3, committed Oct 4, 2026
Size
13,967 bytes
Repository stars
3
License
MIT

Java 单元测试助手。在编写、评审、补全、重构单元测试时使用本技能—— 无论用户是否提到具体框架(unit test / JUnit / Mockito / 测试用例 / 怎么测 / 测哪些 / 写多少)。 次级触发信号——代码或 pom 中出现:spring-boot-starter-test、junit-jupiter、 @Test / @BeforeEach / @ParameterizedTest / @MethodSource、 assertEquals / assertThrows / assertThat / extracting(AssertJ)、 @Mock / @InjectMocks / MockitoAnnotations.openMocks、 mockStatic / MockedStatic、mockito-core; 用户任务词或痛点出现:只写 happy path、补测试不知道写几个、手写一堆重复 @Test、 多条件分支只测一两种、有状态对象只测正常流转、@MockBean 用于纯单测、 测够了没 / 写到什么程度算够、等价类 / 边界值 /…

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:**

- **集合内容断言**(断言 list 元素构成/顺序/提取字段)—— AssertJ 的 `containsExactlyInAnyOrder` / `extracting(...)`。
- **字段分组断言**(同一逻辑组的多个字段作为一个整体校验,如坐标 x/y/z、时间窗 start/end)—— AssertJ 的 `extracting(...).containsExactly(...)`。

**其余场景(简单值、抛异常、各列语义独立的逐列断言如表格型 VO)一律 JUnit 原生,不切换。升级标准可机械执行:是否集合?是否同一逻辑组?两条都不是 → 留在原生逐列断言(失败定位准、加列只改一处)。**

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

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

| 你想做的 | 看这份 | 读多少 |
|---|---|---|
…

Read the whole file at its exact version.

How to install

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

The line at the top of this page pins the label v1.5.3, 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_sddo4wmmxlavbcqz.svg)](https://markdownregistry.com/a/art_sddo4wmmxlavbcqz)

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

Versions

The registry has recorded 1 version of this file, committed on Oct 4, 2026.

versioncommittedcommitsizeaudit
v1.5.3 latest2026-10-04 b24ce00 13,967 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 (13967 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_sddo4wmmxlavbcqz
GET https://markdownregistry.com/api/v1/resolve?ref=baixuanzhu/skills/java-unit-test
GET https://markdownregistry.com/api/v1/blob/7b0d5d93f5cb8744a0e856d383ce737d1de497391a6b568671c43aad6be1867f

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-unit-test/darwin-validation-v1.4.0/snapshots/versionB/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/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

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