Chapter 19
Test-Driven Development
“Pick a little, talk a little, pick a little, talk a little, pick, pick, pick, talk a lot, pick a little more.”
from Meredith Wilson’s musical, The Music Man!
If we replace “pick” with “test” and “talk” with “code,” the song captures the essence of Test-Driven Development: write tests and code in small, incremental, alternating steps. A test case is written first, and, in the absence of the corresponding code, the test case fails when executed. Immediately, just enough code is written so that the test case will pass. (Nota bene: “pass” means the observed outputs are consistent with the expected outputs.) As code size increases, refactoring is permitted, but all the original tests must still pass (otherwise the ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access