Book Review: Test-Driven Development – A Practical Guide

“Failures are the stepping stones to success”. This is very much true of how  Test-driven Development (TDD), an Agile software engineering practice works. Unlike the conventional software development where the programmer writes the code and then tests it out, TDD happens in reverse. It is all about – first writing a test code which will invariably fail since there is no functionality code written yet; then writing just enough functionality code to make the test pass; followed by refactoring that code; and then writing the next test and then the functionality code and  so on till sufficient test cases are created and they all pass when tested with the functionality code after their initial failure.

This book explores TDD through practical hand-on examples and a real project.

It is divided into four parts:

Part I: Background starts with an introductory chapter on TDD followed by chapters on  Refactoring and Programming by Intention.
Refactoring is the process of improving the internal structure of the code without changing its external behavior. This goes hand-in-hand with TDD in order to ensure a clean , efficient and maintainable code. Refactoring refines the kludges (quick-and-dirty solutions) like duplication, hard coding etc., introduced during the process of  doing the simplest thing possible to make the test pass.
The main goal of Programming by Intention is to make the code as understandable and intent-revealing to its readers. This can be achieved through appropriate naming of classes, variables , methods etc. and using the simplest possible algorithm while programming.

Part II:  Tools and Techniques  first introduces JUnit, the defacto standard Java TDD framework through a tutorial and then explores some of the standard and nonstandard extensions to JUnit. Tools that support the use of JUnit and also the ones which are completely independent of JUnit  yet work well with it are also discussed.
The three goals of TDD are – focused tests; independent tests and fast tests. These three goals are apparently conflicting. The concept of Mock Objects is introduced in to resolve this conflict.
Another challenge while using TDD is GUI development. The concluding chapter of this part explains tools and techniques to address this issue.

Part III:  A Java Project – Test-Driven End to End :  Justifying the title of the book , this part works through a TDD in the context of a real project -  development of an application to keep a track of movies which a user may want to see. First the project is defined in terms of an overall vision ,  a set of 10 user stories and a set of 37 tasks into which these stories have been decomposed . Then each of the following chapters demonstrates TDD by  providing an annotated walk through of the  real code written to test the completion of tasks and user stories (Over 100 tests !).

Part IV xUnit Family Members : Some of the other members of the family of  programmer test framework viz; RubyUnit, SUnit, CPPUnit, PyUnit, VBUnit are briefly described in this part using one of the user stories developed discussed in the previous part.

The Appendix of this book include brief introductions and overviews of XP and Agile Modeling.

I was looking for some material on TDD which goes beyond a high level overview. Initially I tried reading “Test Driven Development by Example” by Kent Beck, the developer of this technique. However I found it a bit too informal and loosely structured to my liking and I moved on to this book which I found it to be very systematic.

Recommended for programmers familiar with Java or any  Object oriented programming  language. Not a right choice for readers without programming background.

Book Details: Authors – David Astels ; Paperback  – 592 pages; Published – 2003; Publisher – Prentice Hall.
Buy from Flipkart

Links:

[Please feel free to leave your comments below or bookmark/share this post]

This entry was posted in Book Review and tagged , , , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>