smithery.ai

unit-testing

为 BK-CI 代码编写单?

First seen Mar 20, 2026

Installation

$ npx skills add https://smithery.ai

Similar popular skills

Related neighbors and high-traction skills in the same topics — useful to compare before installing.

Also in this package

Other skills from smithery.ai · top by installs.

npx skills add https://smithery.ai

Browse all from smithery.ai

More details

Agent compatibility

Declared targets from SKILL.md / docs. Unmarked agents are not listed — the skill may still install via the CLI.

Claude Code Not declared
Cursor Not declared
Codex Not declared
GitHub Copilot Not declared
Windsurf Not declared
Gemini CLI Not declared
Cline Not declared
OpenCode Not declared

Package contents

Files included with this skill beyond the listing page.

  • skill md SKILL.md 1,492 B
  • docs SUMMARY.md 252 B

History

  1. First seen on skills.sh
  2. First recorded snapshot · 9 installs

SKILL.md

单元测试

适用场景

  • 编写 Service / DAO / 工具类单元测试
  • Mock 外部依赖和边界条件
  • 验证正常路径、异常路径和回归场景
  • 采用 TDD 或补测试防回归

不适用场景

  • 集成测试、端到端测试
  • 只是实现业务逻辑,不准备补测试
  • 只是排查运行环境问题

快速指导

  1. 这个 skill 关注的是 BK-CI 项目里的单元测试写法,不是测试理论总览。
  2. 测试先保证意图清晰,再考虑覆盖率;重点是关键分支和回归风险。
  3. 常见模式仍然是 AAA、Mock 外部依赖、显式断言结果和交互。
  4. 写测试前先确认你测的是业务规则,不是把实现细节机械复述一遍。
  5. 如果测试涉及后端接口或服务结构,再联动看 backend-microservice-development

高信号规则

  • 正常路径和失败路径都要有代表性覆盖
  • Mock 应该服务于隔离边界,而不是掩盖设计问题
  • 测试命名要能直接表达行为和预期

关键陷阱

  • 只测 happy path
  • Mock 过度,导致测试几乎失去行为价值
  • 断言太弱,只证明代码跑过,没有证明结果正确

延伸阅读

  • 如果你在改后端服务:再看 backend-microservice-development