The Three Rules of TDD
Table of Contents
Robert C. Martin (“Uncle Bob”) provides a concise set of rules for practicing TDD.
-
Write production code only to pass a failing unit test.
-
Write no more of a unit test than sufficient to fail (compilation failures are failures).
-
Write no more production code than necessary to pass the one failing unit test.
Rule #1 says to write tests first—understand and specify, in the form of a unit test example, behavior you must build into the system.
Rule #2 says to proceed as incrementally as possible—after each line you write, get feedback (via compilation or test run) if you can before moving on. When test-driving a RetweetCollection class, we stop as soon as we write this much of a first test:
Comments |0|
Category: 程序人生