Unit Test Frameworks

Unit Test Frameworks
Authors
Paul Hamill
ISBN
0596006896
Published
01 Oct 2004
Purchase online
amazon.com

Unit test frameworks are a key element of popular development methodologies such as eXtreme Programming (XP) and Agile Development. But unit testing has moved far beyond eXtreme Programming; it is now common in many different types of application development. Unit tests help ensure low-level code correctness, reduce software development cycle time, improve developer productivity, and produce more robust software.

Page 2 of 2
  1. Editorial Reviews
  2. Customer Reviews

Customer Reviews

XPSD said
[reviewed by XPSD member Paul Hamill]

Unit testing and test-driven development (TDD) is a skill that has been desperately lacking on many of the projects I have been involved with over the last few years. I have tried reading books by Kent Beck and others on this subject, but I have always had trouble getting to the next level of applying the skills to "real" problems. This book does not take the approach of claiming to teach you how to be a great test-driven developer, instead it is a survey of the unit test tools available for many environments today and along the way explains the fundamentals of unit testing and TDD.

If you have read other books on TDD, you may find much of this book a review, however there are many explanations of how some of these tools would be used in actual projects which I found valuable. The discussion of mock objects is a good one which explained some details about how to use mock objects in practice that I didn't understand in reading other sources on the subject. In addition, several tools I was unaware of were discussed that I am interested in looking into for making TDD easier to do. For example, XMLUnit and NUnitForms are 2 tools that would seem to make testing a data-driven GUI application much more manageable.

I would recommend this book for anyone who has an interest in unit testing or test driven development and wants to know what tools are available to do this. Also, this book would be invaluable if you intend to write your own xUnit framework for a language.

Lasse Koskela said
I had used JUnit for several years before picking up this book and I like to think that I know the tool pretty well. So why did I decide to read this book? I read this book because I thought that might help me venture a bit outside my familiar JUnit turf and into doing test-first programming with languages other than Java. The short version? A very nice introduction to all the included xUnit ports. The long version? Read on.

The first four chapters are general introduction to the topic of unit testing (and to some degree, test-driven development). I was prepared to do a quick scan through them all but ended up reading chapters 3 (xUnit architecture) and 4 (writing unit tests) almost word to word-the topic was mostly familiar but the authors solid writing kind of kept me going.

The first two chapters didn't pique my interest that much, perhaps because I had already seen people develop a unit test framework from scratch as an introduction to the domain.

The real meat of the book that I was looking forward to was in chapters 7 through 9, the introductions to CppUnit, NUnit, PyUnit-which were mostly new to me although I had done very little fooling around with them before. I wasn't disappointed. The author managed to put together a pretty good set of tutorials for these frameworks. Obviously the same information is available online but I still prefer reading a treekiller rather than a printout of a web page.

The not so bright spots in the book, in my opinion, were the chapters on unit testing a Swing GUI and on XMLUnit. Not that they were in anyway badly written. I just felt like they didn't belong. I would've personally swapped in a couple of additional xUnit ports instead (Ruby and PHP, for example).

This is definitely not a book you'll carry with you from project to project. There's approximately 100 pages of substance split among half a dozen topics so none of them gets covered in detail. The rest, almost 100 pages of the book is what I'd classify as "nice to have"-I don't mind having that material in the book but I also wouldn't have minded if they'd left them out.

To summarize, if you'd like to get an idea of how the unit testing frameworks on different platforms/languages differ and what they have in common, this is as good an introduction to them as any and well written in all dimensions. However, you might be disappointed if you're looking for a more long-lasting companion.

Emilio Suarez said
I have been using JUnit for unit testing on Java for quite a while and I have also been exposed to other testing frameworks, but had never looked under the hood is such detail as Paul does in this book.

He starts with a good overview of what a unit test framework and then takes us to a very nice tutorial on building your own unit test framework from scratch. This exercise is very well documented and you learn the basic principles behind a unit test framework while building a simple application and the unit tests required to test it.

After laying out the foundation, he goes on to explain in more detail how to write unit tests, how to use assertions, how to deal and test exceptions and expected errors, how to test protected behavior, how to organize your project for testing and using more advanced techniques like mock objects and performance testing.

He also includes a chapter that deals with testing GUIs (Graphical User Interfaces) which is a challenging task, but he offers good ideas for doing test driven development for a GUI to the application that we have been building during the previous chapters.

After all the basic concepts have been covered, the next chapters are dedicated to the most important (or more popular) unit test frameworks which are JUnit for Java, CppUnit for C++, NUnit for C# on .NET, PyUnit for Python and XMLUnit for XML documents. It is interesting to note that throughout the book the author uses the same application for the example code, so that we can compare the actual implementation of the tests using the different frameworks.

In the appendices, there is a C++ version of the simple Java framework that was built on chapter 2 and there are also summaries of the class reference documentation for JUnit and CppUnit.

Overall I think it is a very solid book with good examples and very concise content. Even though it doesn't cover all the unit test frameworks that exist today, I think it covers the most important ones, but the real gem is on the in-depth analysis of what makes a unit test framework.

If you are already familiar with one or more unit test frameworks, this book will give you a deeper understanding of them, and if you are still programming without writing unit tests... shame on you ;-)... buy this book and learn how simple it is to have a very good unit testing framework, no matter what language you use.

lakeisleofinnisfree said
This is a very solid, no-nonsense introduction to unit test framework.

For a 200 page book, this one is packed with carefully chosen information, detailed enough for new comers to start unit testing, useful enough for a frequently-visited reference, and at the same time concise enough for anyone to get an overview of the unit test landscape.

David N. Thielen said
I have put off writing a review of this book because I had very mixed feelings. On the plus side, it is a very clear concise guide to unit testing - a great introduction.

On the negative side, I figured that any decent programmer already knows what's covered here. Even those who don't write unit tests (bad programmer, bad) knows what they are and how to do it.

Then I was stuck on how to unit test in a particular case and the author email me - look on page 37. And there it was.

So, if you are learning to program - GET THIS BOOK. No one will hire you unless you know this. If you're an experienced programmer, it can still teach you a thing or two.

- dave thielen

ps - the author is a friend of mine and that did cause me to round up my 4.5 rating.

You might also like...

Comments

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“Memory is like an orgasm. It's a lot better if you don't have to fake it.” - Seymour Cray