engram-testing-coverage

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

When to Use

使用场景

Use this skill when:
  • Adding new behavior
  • Fixing a bug
  • Refactoring logic with branch complexity

在以下场景使用本技能:
  • 添加新功能
  • 修复Bug
  • 重构存在分支复杂度的逻辑

TDD Loop

TDD循环

  1. Write a failing test for the target behavior.
  2. Implement the smallest code to pass.
  3. Refactor while keeping tests green.
  4. Add edge/error-path tests before closing.

  1. 针对目标行为编写一个会失败的测试用例。
  2. 编写最少的代码使测试通过。
  3. 在保持测试全部通过的前提下进行重构。
  4. 在完成前添加边界/异常路径测试用例。

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中报告包覆盖率和总覆盖率。