JUnit Recipes

J B Rainsberger

Publisher Manning 2005
ISBN 978-1-932394-23-8
RRP £44.99
Reviewed by Peter Morgan MBCS CITP
Score 8 out of 10

JUnitRecipes This thick volume (700 pages including good references and reading list) is aimed at three groups: Java developers in general, JUnit users, and lastly software testers.

It is very useful to all three groups. As a software tester, I gave it a mark of 8/10. It may merit top marks for the other two readership groups.

JUnit is one of a series of language-dependent packages for those engaged in test driven development. It is important to point out are that the book is describing both the building blocks for JUnit, and a process.

The authors (important contributions from Scott Stirling and others, in addition to JB Rainsberger) make little in the way of assumptions. Not every reader will be an expert Java programmer, nor will everyone have used JUnit before.

Starting from the notion of building little tests as coding progresses, some tough questions are introduced early on. How is production code to be separated from testing code? It is great having a fully rounded regression pack available, but is it possible to invoke only a subset of the tests available? Real questions from genuine situations that scratch where it itches.

All this from the three principles of JUnit: create an object, invoke a method and test the result. Practical examples abound, and there are coded examples, which are for the most part very clear. Later on, some parts were beyond my level of Java technical understanding (particularly testing JavaBeans), but some testing points still emerge.

To build in the future-proofing of test packs, ‘re-factoring’ is mentioned both early, and often. There are also some very common testing items. Here is one for a taster: if a module/class/object has no noticeable effect, why test it (and perhaps more pertinently, why code it). There is also the idea that some items are not building blocks, and are too simple to test. This is surely worth considering.

Development can learn from testing. This volume shows that all the traffic is not one way, and is a valuable addition to (some of) those engaged in software development.

Further information: Manning