The Three Rules of TDD [TDD的三条军规(摘要)]
Author
Zhou Renjian
Create@
2006-08-28 10:07

The Three Rules of TDD
Over the years I have come to describe Test Driven Development in terms of three simple rules. They are:
- You are not allowed to write any production code unless it is to make a failing unit test pass.
- You are not allowed to write any more of a unit test than is sufficient to fail; and compilation failures are failures.
- You are not allowed to write any more production code than is sufficient to pass the one failing unit test.
这些年来,我喜欢下面三条简单的规则来描述测试驱动开发:
- 除非这能让失败的单元测试通过,否则不允许去编写任何的产品代码。
- 只允许编写刚好能够导致失败的单元测试。 (编译失败也属于一种失败)
- 只允许编写刚好能够导致一个单元测试失败的产品代码。