tdd
测试驱动开发 (Test-Driven Development)
哲学 (Philosophy)
核心原则 (Core principle):测试应该通过公共接口验证行为,而不是实现细节。代码可以完全改变;测试不应该。
Tests should verify behavior through public interfaces, not implementation details. Code can change entirely; tests shouldn't.
好测试 (Good tests) 是集成风格的:它们通过公共 API 操作真正的代码路径。它们描述系统做什么,而不是怎么做。一个好测试读起来像一个规格说明——"用户可以用有效的购物车结账"告诉你确切存在什么能力。这些测试在重构中存活,因为它们不关心内部结构。
Good tests are integration-style: they exercise real code paths through public APIs. They describe what the system does, not how it does it. A good test reads like a specification - "user can checkout with valid cart" tells you exactly what capability exists. These tests survive refactors because they don't care about internal structure.
坏测试 (Bad tests) 与实现耦合。它们 mock 内部协作者、测试私有方法、或通过外部方式验证(比如直接查询数据库而不是使用接口)。警告信号:你的测试在重构时失败,但行为没有改变。如果你重命名一个内部函数而测试失败,那些测试是在测试实现,而不是行为。
Bad tests are coupled to implementation. They mock internal collaborators, test private methods, or verify through external means (like querying a database directly instead of using the interface). The warning sign: your test breaks when you refactor, but behavior hasn't changed. If you rename an internal function and tests fail, those tests were testing implementation, not behavior.
见 tests.md 了解示例,mocking.md 了解 mock 指南。
See tests.md for examples and mocking.md for mocking guidelines.
More from ninehills/mattpocock-skills
to-issues
使用曳光弹垂直切片将计划、规格或 PRD 拆分为项目 issue 跟踪器上可独立认领的 issue。当用户想将计划转换为 issue、创建实现工单、或将工作拆分为 issue 时使用。 (Break a plan, spec, or PRD into independently-grabbable issues on the project issue tracker using tracer-bullet vertical slices. Use when user wants to convert a plan into issues, create implementation tickets, or break down work into issues.)
2handoff
将当前对话压缩为交接文档,供另一个 agent 接续工作。 (Compact the current conversation into a handoff document for another agent to pick up.)
1grill-me
对用户的计划或设计进行无情的访谈,直到达成共识,逐个解决决策树的每个分支。当用户想要压力测试计划、被质疑设计或提到"grill me"时使用。 (Interview the user relentlessly about a plan or design until reaching shared understanding, resolving each branch of the decision tree. Use when user wants to stress-test a plan, get grilled on their design, or mentions "grill me".)
1zoom-out
让 agent 拉远视角,对不熟悉的代码区域给出更广泛的上下文或更高层次的视角。当用户不熟悉某段代码或需要理解它如何融入更大图景时使用。 (Tell the agent to zoom out and give broader context or a higher-level perspective. Use when you're unfamiliar with a section of code or need to understand how it fits into the bigger picture.)
1caveman
>
1to-prd
将当前对话上下文转化为 PRD 并发布到项目 issue 跟踪器。当用户想从当前上下文创建 PRD 时使用。 (Turn the current conversation context into a PRD and publish it to the project issue tracker. Use when user wants to create a PRD from the current context.)
1