I’m always looking for ways to learn more about unit testing and TDD, I was elbow deep in a C++ project and I was looking to learn more about the tools & tricks of TDD in the unforgiving C++ world when this book was published and so I’ve started reading it.
This book does two things which I believed to be impossible (or really, really hard) - teach TDD without first explaining about unit testing by using C++.
Don’t be fooled by the title this is not a C++ book, but rather a very good book about TDD – the tooling, how to write a unit test, how to think the TDD way, legacy code – you name it.
After the first chapter which handles the logistic of compiling and setting the development environment (it’s still C++) the book really starts with a good example - easy to understand but not trivial and shows how using TDD and Google Testing framework you can create an emerging design.
The book covers everything I expected from a good unit testing book and more. Other than the obvious red-green-refactor, unit testing (and mocking) frameworks and how to structure a good unit test, there is much more - great topics which could save time and frustration to anyone who practice TDD: there’s a chapter about how to introduce TDD to your peers and supervisors (non techies), a chapter about the Mikado method, a chapter about unit testing and multi-threading and a chapter about creating a sustainable TDD suite – which anyone who failed implementing TDD can really appreciate.
I do not agree with everything in the book – for example I try to avoid using Setup/teardown methods because I’ve seen the horrors that they can become if not managed correctly and I have some thoughts about the ways that some of the tests are structured in the book – but I was relived to find out that this book while teaching on way to write unit tests does not advertise it as the only way and say so towards the last chapter.
I highly recommend this book to anyone who want to learn TDD or improve the way tests are written and designed - not just C++ developers.
So pick up this book and perhaps you can also “Code Better, Sleep Better” or at least understand TDD much better…
Labels: Book review, C++, TDD, Unit tests