skilly. Buy ad slot
All skills
Community / AGENT SKILL

tdd-guide

bryanzk/MyCodexEnv
0 installs 0 GitHub stars
0

强制测试先行的 TDD 工作流,适用于新增功能、修复 bug、重构、关键业务逻辑开发;要求 RED→GREEN→REFACTOR 循环并验证覆盖率至少 80%。

BEFORE YOU INSTALL

Understand the trade-offs.

SECURITY REVIEW

Not yet assessed

Review the original instructions and requested permissions before installing.

No security review is available for this catalog entry yet.

SKILL QUALITY

Not yet assessed

How clearly the skill guides your agent, how complete its workflow is, and how you can check the outcome.

No quality assessment is available for this catalog entry yet.

The full skill.

Original instructions from the publisher’s SKILL.md

# TDD Guide

## 概述

使用该技能来执行严格的测试驱动开发(Test-Driven Development, TDD)流程:先写测试,再写最小实现,最后重构并验证覆盖率。优先保证可验证性与可维护性。

## 工作流(RED → GREEN → REFACTOR)

1. 先定义接口与输入/输出约束(scaffold)
   - 明确函数签名、返回值、错误语义与边界条件。
2. 编写失败测试(RED)
   - 覆盖 happy path、边界条件、错误路径。
   - 测试名称描述行为,不测试实现细节。
3. 运行测试并确认失败原因正确
   - 只允许因未实现/不满足行为而失败。
4. 写最小实现(GREEN)
   - 只实现满足当前测试的最小逻辑。
5. 运行测试并确认全部通过
6. 重构(REFACTOR)
   - 去重、命名优化、性能改进,保持测试绿色。
7. 覆盖率验证
   - 覆盖率 >= 80%;关键业务逻辑目标 100%。

## 执行要点

- 优先发现并复用仓库已有测试入口(如 `test_runner.py`、Makefile 或 CI 脚本)。
- 外部依赖必须 mock;避免网络或全局状态依赖。
- 每个功能完成后立即运行测试,不跨越 RED 阶段。
- 记录验证证据(若仓库有验证记录文件,按要求更新)。

## 参考资料

需要完整检查清单和用例示例时,读取 `references/tdd-checklists.md`。