tdd-workflow
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseFollow the TDD London School (mock-first) approach:
- Write the failing test first -- define expected behavior with mocked dependencies
- Run the test -- confirm it fails for the right reason
- Implement minimal code -- make the test pass with the simplest solution
- Refactor -- clean up while keeping tests green
- Repeat -- add the next behavior
Before starting:
After completing:
mcp__claude-flow__hooks_pre-task({ description: "TDD: FEATURE_NAME" })mcp__claude-flow__hooks_post-task({ taskId: "tdd-FEATURE", success: true, storeResults: true })Principles:
- Mock external dependencies at boundaries
- Test behavior, not implementation
- One assertion per test when possible
- Descriptive names:
should [behavior] when [condition]
遵循TDD伦敦学派(先模拟)方法:
- 先编写失败的测试——使用模拟依赖定义预期行为
- 运行测试——确认测试因正确的原因失败
- 实现最简代码——用最简单的解决方案让测试通过
- 重构——在保持测试通过的前提下清理代码
- 重复——添加下一个功能
开始前执行:
完成后执行:
mcp__claude-flow__hooks_pre-task({ description: "TDD: FEATURE_NAME" })mcp__claude-flow__hooks_post-task({ taskId: "tdd-FEATURE", success: true, storeResults: true })原则:
- 在边界处模拟外部依赖
- 测试行为,而非实现细节
- 尽可能每个测试仅包含一个断言
- 使用描述性命名:
should [behavior] when [condition]