When testing becomes a developer's habit good things tend to happen--good productivity, good code, and good job satisfaction. If you want some of that, there's no better way to start your testing habit, nor to continue feeding it, than with JUnit Recipes.
In this book you will find one hundred and thirty seven solutions to a range of problems, from simple to complex, selected for you by an experienced developer and master tester. Each recipe follows the same organization giving you the problem and its background before discussing your options in solving it.
JUnit—the unit testing framework for Java—is simple to use, but some code can be tricky to test. When you're facing such code you will be glad to have this book. It is a how-to reference full of practical advice on all issues of testing, from how to name your test case classes to how to test complicated J2EE applications. Its valuable advice includes side matters that can have a big payoff, like how to organize your test data or how to manage expensive test resources.
Review By: Brad Appleton 11/28/2005
"JUnit Recipes" is a comprehensive tome of practical methods and techniques for using the open source JUnit tool to develop automated unit tests for Java/J2EE applications. The book is split into four parts. "The Building Blocks" section covers the fundamentals of creating basic tests using JUnit, organizing and managing test suites and test data, running JUnit tests, and reporting the results. It also includes a section on troubleshooting. "Testing J2EE" covers XML, JDBC, EJB, Web components (including JSPs), and J2EE applications. Additional techniques include testing some well-known design patterns, using JUnit add-ons and JUnit libraries (like GSBase). The appendices include complete solutions, some short and sweet essays on testing, and a modest recommended reading list.
The author's organization of the book flows very logically and the writing style is very clear and easy to follow. Along the way many insights into important design principles and testing techniques are revealed. The reader will learn about the Hollywood principle, the open-closed principle, design patterns, POJOs, mock objects, private and parameterized test-cases, abstract test-cases, self-shunts, and more. The book is very comprehensive and touches on many other popular Java/Enterprise projects and frameworks such as Struts, JBOSS, XPath, XMLUnit, HTTPUnit, Ant, and others.
Even though JUnit is often associated with Agile development and much of the wisdom apparent in the book applies to Agile Java development, the book is useful to any Java developer on any Java project, Agile or otherwise. The author goes into considerable detail, with working code examples, to spell out exactly how to perform and apply the techniques described.
Java testers will also find some good nuggets of information but it's quite clear that Java programmers and developers make up the target audience. This isn't some high-level theoretical book mostly composed of concepts and ideas. The book is not a how-to for coming "up-to-speed" on setting up and running JUnit. Another book from the same publisher, "JUnit in Action," is a great overview on learning more about the basics of running JUnit and using it to tackle a number of basic challenges with unit testing Java and J2EE code. "JUnit Recipes" has some overlapping material but basically picks up where "JUnit in Action" leaves off, and "JUnit Recipes" goes into much more breadth and depth of JUnit methods, practices, techniques, and use with other Java projects and frameworks. "JUnit Recipes" should probably be mandatory reading for anyone using Java, J2EE, and JUnit in the real world. This comprehensive and imminently pragmatic guide not only conveys a great deal of highly practical wisdom but also clearly demonstrates and explains the code to accomplish and apply the techniques described.