REVIEW - Test-driven Development - By Example


Title:

Test-driven Development

By Example

Author:

Kent Beck

ISBN:

Publisher:

Addison-Wesley Professional (2003)

Pages:

220pp

Reviewer:

John Mullins

Reviewed:

February 2004

Rating:

★★★★★


Without doubt, one of the best books I have read this year.

Kent Beck introduces the reader to a technique of software design driven by tests, the aim being to develop "clean code that works - now".

The first part the book consists of two tutorials that demonstrate of examples of organically growing software by first writing a test to exercise a piece of functionality and then writing the code to make that test pass and then refactoring to remove duplication. The author shows how to move in very small steps when working through particularly sticky areas of code or move in larger steps when confidence permits. Beck uses the tests to inspire confidence in the code being developed, and to continually drive the development forward. Beck also emphasizes that tests should be easy and quick to run (if they are not they unlikely to be run as often as they should) and introduces the test framework JUnit, a tool for automating the running of tests.

The first tutorial is fairly lightweight and consists of developing a multi-currency class in Java. Here we are introduced to the various ways the author uses to quickly get failing tests to pass. There is much emphasis on the red/green bar, which refers to the JUnit framework that uses a red bar to indicate failure and a green bar to indicate success. The author does not like having a 'red bar' for any significant length of time and shows how to quickly get to green (often using any means necessary), i.e. to get to the "code that works" stage, before turning that into "clean code". The second tutorial is slightly more heavyweight and describes the development of the above-mentioned testing framework in Python. Here we gain more insights like how do we start to write tests to test the framework we will be using to write tests and why and how to isolate our tests from one another.

The final part of the book discusses various testing patterns, design patterns, refactoring, and where to go from here. There is a whole list of patterns you can add to your arsenal of tools to keep the bar green. Beck describes the refactorings that are common in TDD and how their use differs slightly from the classic view presented by Martin Fowler in his book on the topic. There is also a discussion of where we have difficulty using Test Driven Development, such as GUI development.

The book is very easy to read, the authors style is very relaxed and he is clearly very enthusiastic about the story he has to tell. The book packs in an awful lot considering it is just over 200 pages long, if you wish to experiment with TDD everything you need to get started is here. Without doubt, one of the best books I have read this year, Highly Recommended.


Book cover image courtesy of Open Library.





Your Privacy

By clicking "Accept Non-Essential Cookies" you agree ACCU can store non-essential cookies on your device and disclose information in accordance with our Privacy Policy and Cookie Policy.

Current Setting: Non-Essential Cookies REJECTED


By clicking "Include Third Party Content" you agree ACCU can forward your IP address to third-party sites (such as YouTube) to enhance the information presented on this site, and that third-party sites may store cookies on your device.

Current Setting: Third Party Content EXCLUDED



Settings can be changed at any time from the Cookie Policy page.