JUnit in Action

Vincent Massol, Ted Husted (2003)
Review date: August, 2008 (Read in March 2008)

The first 100 pages of this book are pure vanilla on testing. As usual, JUnit 3.x is explained in conjunction with descriptions of different test types and the usual "what to test" discussion. One feature makes this intro unique though: there are examples of how to run tests using Ant, Maven, and Eclipse.

Chapter six covers stubbing, and the authors use Jetty and a stubbed protocol handler to show how to test something that relies on a web server. You don't see that approach every day, at least not I. Then comes a chapter on mock objects, starting with hand-written mocks, ending with Easymock. The good part is that the same scenario as described in the preceding chapter is tested again, this time using another technique.

Following, no fewer than three chapters are dedicated to Cactus and how to use it to test servlets and JSPs.

In fact, half of the following chapter is also heavy on Cactus, but this time database tests are the target. The book ends with a chapter on how to unit test EJBs and some more final words on Cactus.


First and most important impression: too much Cactus! In addition to that, too much code. Now don't get me wrong. No explanation beats a good example, and example code does speak for itself, but this book proves that you actually can have too much of that. In fact, the second half of the book is so cluttered with code that I found it hard to read.

My review may be affected by the fact that I perceive Cactus as old, clumsy, and not really usable anymore. In 2008 we have better techniques and frameworks to assist us in testing! This Cactus intensity makes the book outdated, and since it contains relatively little "generic knowledge", such as testing principles, and lots of code instead, it offers little value today. I bet that it was really usable around 2003-2004, when it was written. In short, this will not became an eternally quoted classic. Trust me.

Apart from that obvious shortcoming, if you need an intro to JUnit, you're not worse of reading this book's first five chapters than reading another book's intro. People new to actually setting projects up may find this part helpful.

Bonus for the creativity in using Jetty for web resource testing. I haven't seen that approach before, but that may be because of the fact that you would design these things differently and thus enable simpler testing. Anyway, since that approach is described too, I guess we only reap the benefits...

On the whole I'd say that I find a lot of the techniques used in this book quite awkward. I get the feeling that the example problems could be tackled with simpler approaches, but obviously they weren't available at the time of writing (or were they ?). In that light, this book gives you some new ideas... but not really practical ones.

To sum this up: read if you want a history lesson and some new tricks, don't read if you just want to test your code.

Who should read this book

With so many better books out there on testing, I can't really recommend this book. Maybe if you have some legacy Cactus-based tests you might find something helpful here, but probably not. Buy another book on testing!


  • 2015-09-29

    It's been almost one and a half year since I reviwed a book! I've been too absorbed by Writing my own. Anyway, I'm back with Jeff Patton's relatively...
  • 2014-01-04

    New category! Performance! Reviewed The Every Computer Performance Book. Check it out!
  • 2013-09-10

    Reviewed a book that' slightly less technical, but much more fun to read. It's I.T. Confidential.
  • 2013-08-13

    Reviewed yet another book on Visual Studio 2012 and TFS. I also created a "Microsoft" category and moved the other TFS book there from the "Tools"...
  • 2013-08-05

    Updated the FAQ. Included information about getting a book reviewed.