Test-driven development has a lot to recommend itself:
- Testable code is usually well structured
- Specifying tests deepens the understanding of what the code is meant to achieve
- It makes sure tests are actually written, not omitted in the end (due to time constraints or “Why test? It works!”)
Unfortunately it’s not as easy as it looks at first sight (“Just add some tests, how hard can it be?”). Rather, writing testable code is a whole new skill set in its own right.
Here’s a selection of links I found useful:
- Nice intro on why and how to develop test-driven
- Great talk on how to design for testability
(Also check out Miško Hevery’s other talks)
- Scope and setup of tests and why “behavior-driven design” is a more accurate name than TDD
In this article Dan North also proposes the “Given, when, then”-format. This format is great to clearify behavior, even if you don’t use TDD / BDD.
- Field report of a developer on how his testing activities changed towards TDD over the years
- Why not have a TDD code retreat to kickstart your TDD abilities?
What would you recommend to someone starting out with TDD?