I earlier wrote about the book, The Art of Unit Testing, which I finished a while ago. That book was very good and was focused on how to write good unit tests. It also mentioned Test-Driven Development, TDD, but not too much. The book I read next, which I finished a few days ago, was kind of the other way around. Pretty much only about TDD. And from the title, Test-Driven Development: By Example, that shouldn’t be much of a shocker 😛
The book is written by Kent Beck and explains the basics about TDD. It does this pretty well, step by step, by example, just like the title says. The book also talks some about TDD in a more general sense. What it is, how it works, why it works, et cetera.
From the back-cover:
Readers will learn to:
- Solve complicated tasks, beginning with the simple and proceeding to the more complex.
- Write automated tests before coding.
- Grow a design organically by refactoring to add design decisions one at a time.
- Create tests for more complicated logic, including reflection and exceptions.
- Use patterns to decide what tests to write.
- Create tests using xUnit, the architecture at the heart of many programmer-oriented testing tools.
It pretty much kept the promises 🙂 The only part I didn’t really like about this book was that I found much of the coding kind of messy. Could be because the languages used in the examples are Java and Python, which I don’t really like that much syntax-wise. An even more important reason though, is that I just finished reading The Art of Unit Testing 😛 So, I suppose I have become a bit demanding when it comes to cleanliness when coding and writing unit-tests. I suppose that is a good thing 😀 (I do however not claim in any way that the code I currently write is extremely clean in any way! But I do strive for it to be so 😉 )
I can really recommend this book to anyone who are curious to get familiar with TDD. I certainly see the value of doing TDD and is in the process of trying to incorporate it into my development habits.
- Red — Write a little test that doesn’t work, and perhaps doesn’t even compile at first.
- Green — Make the test work quicky, committing whatever sins necessary in the process.
- Refactor — Eliminate all of the duplication created in merely getting the test to work.
Red/green/refactor — the TDD mantra.
You can get it at Amazon, and probably a lot of other places too as it is a pretty well-known book.