Skip to content
Back to skills

Unit Testing

ASecurity

要给刚改过的代码补单元测试、补齐边界用例时使用。生成测试、运行并汇报覆盖情况。

  • 7 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added December 1, 2026
ai-agentstestinggitapi

Works with

  • api

Security analysis

A100/100

Pro scans all 4 files and shows the line behind each finding

Scanned December 1, 2026

npx -y skills add code2rich/rigdepot --skill unit-testing --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Unit Testing?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Unit Testing
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/code2rich-unit-testing-5e870ac2/badge)](https://www.skillsdirectory.com/skills/code2rich-unit-testing-5e870ac2)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: unit-testing
description: 要给刚改过的代码补单元测试、补齐边界用例时使用。生成测试、运行并汇报覆盖情况。
---

# 单元测试

## 步骤

1. 找出这次改动涉及的类和方法(`git diff --name-only` 对比目标分支)。
2. 为每个公开方法写测试:正常路径一个,边界和异常各至少一个。边界怎么找见 `references/boundaries.md`。
3. 运行测试,报告写到 `$TEST_REPORT_DIR`。
4. 汇报:新增了哪些测试、哪些失败、覆盖不到的地方和原因。

## 本机配置

`.env.example` 列了要配的项。`SHOP_TEST_API_TOKEN` 是个人密钥,不在本机配置里填。

## 不要做

- 不要为了让测试通过去改被测代码,发现缺陷先报告。
- 不要在测试里写真实的地址和令牌,用 `example.com` 和测试替身。

Files in this skill

  • .env.example286 B
  • SKILL.md855 B
  • meta.yaml582 B
  • references/boundaries.md274 B

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in ai-agents →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.