Install any skill in seconds. Free to start, no credit card required.
Get Started Free →devcxl/tdd
测试驱动开发。当用户想以测试先行构建功能或修复 bug、提到 "red-green-refactor",或想要集成测试时使用。
Passed 21 of 22 test cases with the skill, and 11 of 22 without it.
and 18 more in the full report
10 fixed11 passed either way1 still failing0 broke
Tokens, turns and time describe resource use, not a dollar price.
One of 10 test cases the skill fixed. Same model, same prompt, with and without the skill.
我准备为系统的支付网关集成模块编写单元和集成测试。请帮我按照标准的 TDD 流程规划测试方案:指出应该暴露哪些公共测试接口并说明其作用,然后协助我按步推进第一块功能的测试与实现。
| Checked | Without skill | With skill |
|---|---|---|
| The response requests user confirmation on proposed interface seams before writing tests. | Missed | Passed |
| The response explains what each proposed seam catches and misses. | Missed | Passed |
| The response excludes Refactor from the TDD loop steps. | Missed | Passed |
The instructions your model reads when the skill loads.
TDD 是红 → 绿的循环。本技能是让这个循环产出值得保留的测试的参考:好测试是什么、测试放在哪里、反模式有哪些、循环的规则是什么。每一节在每一个循环中都适用——在循环之前和之中查阅它们,而不是之后。
探索代码库时,读 GLOSSARY.md(如果存在),让测试名称和接口词汇与项目的领域语言一致,并尊重你正在触碰的区域的 ADR。
测试通过公共接口验证行为,而不是实现细节。代码可以彻底改变;测试不应该。好测试读起来像一份规格——"用户可以用有效购物车结账"精确地告诉你存在什么能力——而且因为它不关心内部结构,能在重构中存活。
示例见 tests.md,mocking 指南见 mocking.md。
**接缝(seam)**是你测试所在的公共边界:在不伸手进内部的情况下观察行为的接口。测试住在接缝处,绝不对着内部。
只在预先约定的接缝处测试。 写任何测试之前,写下要测试的接缝并与用户确认。没有测试写在未经确认的接缝上。你不可能测试所有东西——提前约定接缝,正是让测试精力落在关键路径和复杂逻辑上、而不是每个边界情况上的方法。
问:"公共接口是什么,我们应该测试哪些接缝?" 为每个建议的 seam 附上一行说明,指出它能捕获什么、会漏掉什么。
当接口的形态本身存疑时——模块该有多深、接缝该在哪里、接口应该暴露什么——调用 Skill 工具并传入 "codebase-design" 来获得词汇。它是 module、interface、depth、seam、adapter、leverage、locality 这些词的共享来源,是一份供查阅的参考,而不是要跑的一场会话。
expect(add(a, b)).toBe(a + b)、以同样方式手工推导出的快照、断言常量等于自身),所以它构造性地通过,永远不可能与代码相左。期望值必须来自独立的真实来源——已知正确的字面量、手算的示例、规格。code-review 技能),不属于红 → 绿实现循环。test cases passed, vs 11 / 22 without
Published skills whose descriptions closely match this one, with their headline benchmark lift.
More skills from the same source and nearby in the registry, with their headline benchmark lift.