The Art of Unit TestingThe Art of Unit Testing: With Examples in .NET by Roy Osherove

My rating: 5 of 5 stars



Dear Readers!

It is a new year and the Christmas holidays are over, so it is time to get back to business. As such, I’m pleased to announce that I finished reading yet another great book, this time about unit testing. The review, that I posted on Goodreads as usual, is quoted below unchanged and in its entirety. Please enjoy.

As with many other things, sometimes it is hard to know where to start to explore a new topic of interest, and TDD and unit testing itself was no exception from this. Fortunately for us, the above situation is no longer the case for the aforementioned subjects, as R. Osherove presents us with an excellent starting point with his book (I read the 2nd edition). Before going into (some) specifics though, it is important to note that this book is not about TDD (although it touches the subject), but rather about the technicalities of unit testing. And excellent technicalities it gives.

At first glance, the title might be a bit intimidating: “The Art of Unit Testing”. To some, it might translate as “The Finer Aspects of Unit Testing”, inferring, that you have to be a pro to gain any benefit from it. But, thanks to the author’s good presentation skills, this can’t be farther away from the truth, as people with any or no skills will equally benefit from it. As a matter of fact, it ensures this by starting from the very basic topics, like explaining what units, tests and unit tests are and what they are not, what makes them useful, what unit testing frameworks can be used and why they should be used, etc.

The book then dives into more serious stuff like making a very clean distinction between stubs and mocks, giving useful advice and examples when and how these should be used, showing how to refactor code for testability, when and how to use isolation frameworks, what types isolation frameworks have and what advantages/disadvantages they have, how to write and organize unit tests for reliability, readability and maintainability and more. The book finally touches finer aspects, like how to integrate unit testing into organization, what will make you fail or succeed in this quest, and how to be an effective constructive person in general. It also gives a good intro about how to work with legacy code from a unit testing perspective, and what considerations one has to make when deciding for or against testing parts of a legacy code base.

All in all, I’m very satisfied with this book, as it steadily builds a fair understanding of this very important programming topic from the ground, and does so by presenting plentiful (C#) code examples. Also, the code presented in the book is easily comprehensible even by those, who do not have any prior knowledge of the particular programming language (including me), as no language über-specific features are used. I must also emphasize the fact, that the author quite frequently gives very useful “further reading” recommendations throughout the book, which I personally think to be a very nice touch.

So, do I have some complaints? I honestly cannot think of one. I really enjoyed it from beginning to end, so the only thing left to say is that I highly recommend this to anyone interested in unit testing.

As always, thanks for reading.

View all my reviews