Book Review: The Art of Unit Testing (Roy Osherove)

TAOUT I have just finished reading “The Art of Unit Testing with Examples in .NET” by Roy Osherove.

I thought I would take some time out to give you a brief précis of the books content and share my thoughts on the book as a whole.

What Is the Book About?

The book covers using automated (code-based) testing to improve the quality of your code. The idea being that we write additional code that pokes and prods the classes in our production code to ensure it operates as expected.

While examples are given in .NET, the principles and practices are transferable to other modern programming languages such as Java.

What is the Book NOT About?

While some concepts are covered in the book – such as TDD (Test Driven Development) the book is NOT focused on these. The title of the book is very fitting since Roy has done a great job at staying focused on one topic – writing good testable code with good unit tests.

Do not get this book if you are looking for in-depth discussion on:

  • Test Driven Development
  • Behaviour Driven Development
  • Continuous Integration
  • Agile Development
  • Specific Tools

I would also say that this book is really for those that truly want to write code. This is not a “teach yourself in 30 seconds by copying this code” kind of book. It covers the concepts and processes to give you the ability to write the code. There is no companion CD with lots of code to check out.

Summary of Content

Here I will give a quick run-down of the books content and pass my thoughts..

Chapters 1-5

The first half of the book covers the basic concept of “unit testing”, what makes a good unit test as well as what code is testable. There are also chapters on fundamental concepts such as Dependency Injection, Inversion of Control, Isolation (Mocking) Frameworks and the core different between a Mock and a Stub (many people do not know). I think it is great that Roy covers these early on since they make a world of difference to testing (I remember when I first started testing using Debug.Asserts!).

Chapters 6-9

For me, this is where we started getting to the “good stuff”. Roy talks about Writing Maintainable Tests, Static Analysis, Continuous Integration, Introducing Unit Testing to a Team and Working with Legacy Code.

Appendices

To finish the book nicely, there is a couple of appendices that cover Design and Testability and of course a round up of the many tools available to help with Unit Testing.

In Summary

An excellent book, I would recommend it if:

  • You are completely new to Unit Testing.
  • You have been Unit Testing for a short while and looking to see what the next step for you is.

If you have been a hardcore TDD practitioner for years, then I would expect that this book is not for you since you would have likely hashed all the issues covered in the book.

There are a lot of great anecdotes in the book, many of which rang home with me and personal experience. Which (for me) just affirms that the content is good.

A real nice, relatively short read. Great job Roy!

Comments

Popular posts from this blog

GTD: Biphasic Sleep Experiment – Day 4

Visual Studio: Unknown Build Error (HRESULT 0x80131515)

TDD – Getting Started with Test-Driven Development