HTML and CSS Reference
I n Chapter 1, Automated Testing, we were introduced to the unit test, and learned
how it can help reduce the number of defects, catch regressions, and increase de-
veloper productivity by reducing the need to manually test and tinker with code. In
this chapter we are going to turn our focus from testing to specification as we delve
into test-driven development. Test-driven development (TDD) is a programming
technique that moves unit tests to the front row, making them the primary entry
point to production code. In test-driven development tests are written as specifica-
tion before writing production code. This practice has a host of benefits, including
better testability, cleaner interfaces, and improved developer confidence.
In his book, Test-Driven Development By Example , Kent Beck states that the goal
of test-driven development is Clean code that works. TDD is an iterative develop-
ment process in which each iteration starts by writing a test that forms a part of
the specification we are implementing. The short iterations allow for more instant
feedback on the code we are writing, and bad design decisions are easier to catch.
By writing the tests before any production code, good unit test coverage comes with
the territory, but that is merely a welcome side effect.