Red-Green-Refactor – From Failure Through Success until Perfection

"Knowing is not enough; we must apply. Willing is not enough; we must do."
– Bruce Lee

The Red-Green-Refactor technique is the basis of test-driven development (TDD). It is a game of ping pong in which we are switching between tests and implementation code at great speed. We'll fail, then we'll succeed, and, finally, we'll improve.

We'll develop a Tic-Tac-Toe game by going through each requirement one at a time. We'll write a test and see if it fails. Then, we'll write code that implements that test, run all the tests, and see them succeed. Finally, we'll refactor the code and try to make it better. This process will be repeated many times until all the requirements are successfully ...

Get Test-Driven Java Development - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.