tdd
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseTDD
TDD
Loop
循环
- Red — write one failing check for the next behaviour slice.
- Green — make the smallest implementation pass.
- Refactor — simplify while the check stays green.
- Repeat until the contract is covered.
- Red — 为下一个行为切片编写一个失败的检查。
- Green — 用最小实现使检查通过。
- Refactor — 在检查保持通过的同时简化实现。
- 重复上述过程,直到覆盖完整契约。
Output
输出
Name every phase: , , , . Finish with: , , (none or remaining edge).
RedGreenRefactorRepeatPassing checkNormal commandUntestableCompletion: every requested behavior has a passing check, the check ran in the repo's normal command, and any untestable edge is reported.
逐一列出每个阶段:、、、。最后以以下内容结束:、、(无或剩余边缘情况)。
RedGreenRefactorRepeatPassing checkNormal commandUntestable完成标准:每个要求的行为都有通过的检查,检查通过仓库的常规命令运行,并且已报告任何无法测试的边缘情况。
Test choice
测试选择
Prefer the highest-level test that proves the behaviour without brittle setup. HTTP paths: request/response tests. Service/repository: integration tests when practical. Go: table-driven with if project uses it. Keep mocks at boundaries. Do not mock what you can run cheaply. One -style self-check suffices for tiny cases.
testify/requireassert优先选择能够证明行为且不需要脆弱测试设置的最高层级测试。对于 HTTP 路径,使用请求/响应测试。对于 Service/Repository,在可行时使用集成测试。对于 Go,如果项目使用 ,则采用 table-driven 测试。将 mock 保留在系统边界。不要 mock 那些可以低成本实际运行的部分。对于极小场景,一个 风格的自检即可满足要求。
testify/requireassert