engram-testing-coverage
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseWhen to Use
使用场景
Use this skill when:
- Adding new behavior
- Fixing a bug
- Refactoring logic with branch complexity
在以下场景使用本技能:
- 添加新功能
- 修复Bug
- 重构存在分支复杂度的逻辑
TDD Loop
TDD循环
- Write a failing test for the target behavior.
- Implement the smallest code to pass.
- Refactor while keeping tests green.
- Add edge/error-path tests before closing.
- 针对目标行为编写一个会失败的测试用例。
- 编写最少的代码使测试通过。
- 在保持测试全部通过的前提下进行重构。
- 在完成前添加边界/异常路径测试用例。
Coverage Rules
覆盖率规则
- Cover happy path + error paths + edge cases.
- Prefer deterministic tests over flaky integration paths.
- Add seams only when branches are impossible to trigger naturally.
- Keep runtime behavior unchanged when adding seams.
- 覆盖正常流程 + 异常流程 + 边界场景。
- 优先选择确定性测试,而非不稳定的集成路径测试。
- 仅当分支无法自然触发时才添加测试接缝(seams)。
- 添加接缝时保持运行时行为不变。
Validation Commands
验证命令
Run:
bash
go test ./...
go test -cover ./...Report package coverage and total coverage in the PR.
运行:
bash
go test ./...
go test -cover ./...在PR中报告包覆盖率和总覆盖率。