Just finished this one today... I got to fess up - that I am a "classicist". I've seen some real spaghetti tests involving mocks.. But I've gotten some periodic tension from the people on the other side of this religious fence of TDD. Since this book comes from "the torch-bearers of the mockist camp", I picked up a copy and tried to keep an open mind. And I although I haven't switched camps.. I now see the light. There is no one right path but the authors have placed some industrial strength beacons on this path and teach you how to use mocks and interaction tests to "grow" applications driven by automated tests. (However I still maintain that in untrained hands, Mocks (like C++) can be very dangerous and quickly lead into tarpits. Easy to abuse. However in the right hands, they can be used to write very expressive code & enable rapid and iterative development. ).
Some of the key takeaways for me were:
- Developing outside-in ATDD: writing a 'walking skeleton' first , spotting objects and roles (relationships) between them, TDDing these objects and "folding them back" into a running app was a new method to me.
- Listening to the tests, Focus on readability, tests with helpful diagnostics / failure messages, eliminating or reducing the irrelevant part of the test, use of builders + drivers to keep the tests concise
- The chapters on threads and asynchronous testing are home-runs. Don't leave for work without it. The last third of the book was worth the price of the book (It isn't yet available in India so had to get it from overseas).
As the book rightly says, TDD that isn't sustainable will slowly choke the project, tests turn into maintenance headaches and strangles development progress. This is the part that trips most people up with TDD - Kent Beck's book on TDD and most of the literature out there detail the basic technique (with an assumption that you would figure out the exact steps that you need to take in your specific context). The skill of "listening to the tests" isn't easy to pickup or practice for most people. Freeman, Pryce et. all have come up with a more prescriptive method that should keep beginners on the rails.
I followed along to the AuctionSniper example using my own style (and .net, nUnit, Moq + White instead of java, jUnit, jMock + WindowLicker as in the book) in order to compare and contrast. The example isn't trivial (deals with multiple-threads, third party server and protocol (XMPP) and was well chosen.
The final solution was different from the solution in the book; but still passed all the tests. The authors emphasize test readability, which is a 'Can do better' item for me.
Final word: This book is a must-read for intermediate and advanced programmers interested in gaining mastery over TDD. I'd place it on the top-shelf right next to Beck's XP Book, TDD Book & Fowler's Refactoring book. It doesn't have any radical new ideas however it does teach you the right guiding principles to survive in the real world today. It says a lot of things that needed to be said at this point of time... for that I'd give it a 9/10.
Note: The book also has a companion site, with a responsive discussion forum.