/unit-testing
为 BK-CI 代码编写单元测试时使用,例如 JUnit5、MockK、测试组织、依赖 Mock、异常校验和 TDD 场景。当用户要补测试或用测试驱动实现时优先使用。
$ npx -y skills add tencentblueking/bk-ci --skill unit-testing --agent claude-codeHow it fires
How this skill gets triggered: by you, by Claude, or both.
- Fires itselfAuto-invocation. Claude auto-loads it when your prompt matches the work.Auto-invocation is when the right skill fires by itself at the right moment, driven by a FLOW.md router and a hook, instead of you invoking it by name. It is the difference between a skill being installed and a skill actually getting used.Read the full definition →
- You can call itInvoke it directly when you want it.
- Slash command
/unit-testing
Context preview
The summary Claude sees to decide when to auto-load this skill.
为 BK-CI 代码编写单元测试时使用,例如 JUnit5、MockK、测试组织、依赖 Mock、异常校验和 TDD 场景。当用户要补测试或用测试驱动实现时优先使用。
SKILL.md
unit-testing.SKILL.mdname: unit-testing description: 为 BK-CI 代码编写单元测试时使用,例如 JUnit5、MockK、测试组织、依赖 Mock、异常校验和 TDD 场景。当用户要补测试或用测试驱动实现时优先使用。
单元测试
适用场景
- 编写 Service / DAO / 工具类单元测试
- Mock 外部依赖和边界条件
- 验证正常路径、异常路径和回归场景
- 采用 TDD 或补测试防回归
不适用场景
- 集成测试、端到端测试
- 只是实现业务逻辑,不准备补测试
- 只是排查运行环境问题
快速指导
1. 这个 skill 关注的是 BK-CI 项目里的单元测试写法,不是测试理论总览。 2. 测试先保证意图清晰,再考虑覆盖率;重点是关键分支和回归风险。 3. 常见模式仍然是 AAA、Mock 外部依赖、显式断言结果和交互。 4. 写测试前先确认你测的是业务规则,不是把实现细节机械复述一遍。 5. 如果测试涉及后端接口或服务结构,再联动看 `backend-microservice-development`。
高信号规则
- 正常路径和失败路径都要有代表性覆盖
- Mock 应该服务于隔离边界,而不是掩盖设计问题
- 测试命名要能直接表达行为和预期
关键陷阱
- 只测 happy path
- Mock 过度,导致测试几乎失去行为价值
- 断言太弱,只证明代码跑过,没有证明结果正确
延伸阅读
- 如果你在改后端服务:再看 `backend-microservice-development`
Other skills on bk-ci.
- /00-bkci-global-architecture
用于跨模块开发、排查链路归属、判断某个需求应该落在哪个 BK-CI 模块,或需要快速理解流水线全链路协作时使用。单模块修改时优先读取对应模块 skill,而不是停留在这里。
Open skill - /agent-module-architecture
处理 BK-CI Agent 构建机侧能力时使用,例如守护进程、心跳、Ask 轮询、任务拉起、升级更新和与 Dispatch/Worker 的协作。当用户要改构建机宿主侧行为而不是 Worker 执行细节时优先使用。
Open skill - /api-interface-design
设计 BK-CI API 契约时使用,例如 Resource 路径设计、HTTP 方法选择、请求响应对象、错误码和版本策略。当用户要定义接口而不是实现业务逻辑时优先使用。
Open skill - /artifactory-module-architecture
处理 BK-CI 制品上传下载、制品元数据、BkRepo 或磁盘后端存储、文件任务和清理链路时使用。当用户提到构建产物、制品归档、下载令牌、报告文件、BkRepo 集成或制品清理时优先使用。
Open skill - /auth-module-architecture
处理 BK-CI Auth 模块时使用,例如 RBAC 权限校验、用户组与资源管理、IAM 集成、授权迁移和 OAuth2 认证。当用户要改权限平台实现而不是单次权限模型变更时优先使用。
Open skill - /backend-microservice-development
编写 BK-CI 后端微服务代码时使用,例如新增 Resource、组织 API/Service/DAO 分层、依赖注入、服务归属判断和 Spring Boot 开发约定。当用户要做 Kotlin/Java 后端开发时优先使用。
Open skill

