The Art of Unit Testing

The book cover of The Art of Unit Testing

Have you gone through three years of computer science bachelor degree fun (or anything similar) and pretty much not heard a word about testing? Or have you heard from all your teachers that testing is extremely important, but never learned how to even write one? That has been the case for me.

Testing is important, you all got to do it, it is very important, always test, do it a lot!

Well, sure... but how do I do it? How do I write one of these tests?

The last book I finished is called The Art of Unit Testing, and I am so happy that I stumbled over that book. Spring 2009 I was at a developer conference called NDC 2009 (Norwegian Developer Conference) and it was really great. If you have the time, you should go to that website and have a look. You can watch most of the talks there online. Anyways, the second day I attended a series of talks about Test Driven Development with a great speaker called Roy Osherove. I learned a bunch and decided that TDD looks like something I should try to learn. However, I had a big problem. I didn't even know how to write a test. And doing TDD without knowing how to write a test is kind of difficult... to say the least...

Anyways, this Roy Osherove person advertised that he had just finished a book about pretty much exactly that; writing unit tests. So, I decided to get myself a copy of it.

It was great! Seriously learned a lot. It covers the following subjects (yes, that would be the table of contents).

  1. The basics of unit testing
  2. A first unit test
  3. Using stubs to break dependencies
  4. Interaction testing using mock objects
  5. Isolation (mock object) frameworks
  6. Test hierarchies and organization
  7. The pillars of good tests
  8. Integrating unit testing into the organization
  9. Design and testability (Appendix A)
  10. Extra tools and frameworks (Appendix B)

It is only 283 pages long (including the appendixes) and a pretty quick and easy read. Which I like. I got sucked in, and it was finished fast. Probably should read it again some time. πŸ˜› But anyways: I previously did not even know how to write a single unit test in any language. Now I do. πŸ™‚

You can get it from for example Manning (who is the publisher) or from Amazon. I would probably get it from Amazon since they seem to have a 34% discount currently... Except I already have it, of course πŸ˜›

If you want to learn how to do unit testing, I can recommend it with all my heart πŸ™‚

Oh, by the way, when you buy this book, you even get a free eBook version of it! Which is totally brilliant, since then you can have the book and read it at home, but you can also for example put the eBook version on your netbook and read while travelling. Awesome all the way 😎 Wish more publishers or authors (or whoever decides) were like that...