This site will look much better in a browser that supports web standards, but it is accessible to any browser or Internet device.

The Open Source Zone


JUnit Recipes: Practical Methods for Programmer Testing

Book cover

by J. B. Rainsberger

ASIN: 1932394230

See more on Amazon.com

Average Customer Review: 5.0, based on 20 reviews.

Customer reviews (5 of 20)

More than just recipes, 2007-10-09, Rating: 5.

This is a readable, practical, and deep book. It's one of those books which teaches or refreshes Java and OO theory and practice as you read. I am also reading it for pleasure!

The Best Programming Book I know, 2007-03-09, Rating: 5.

This is a great book. It is directed at users of JUnit, the Java unit testing framework. But in my mind the book gives sound advice for solving your programming problems in general, not just for Java or JUnit testing. It stresses the importance of unit testing, programming to interfaces instead of implementations and just simple common sense. The author is clearly passionate about his field and extremely experiences. The combination of enthusiasm and experience comes through on every page.

Excellent coverage of advanced unit testing, 2006-01-19, Rating: 5.

Rainsberger does a very good job of detailing the techniques to unit test difficult code; including xml, ejb, servlets, jsps etc.

Put this next to Knuth and The Gang of Four on your bookshelf, 2005-12-31, Rating: 4.

This isn't necessarily the best introduction for absolute beginners (I would recommend /Pragmatic Unit Testing/ for that), but it is required reading for server-side Java, as most other reviewers have pointed out. But it's more than that--it's one of those rare computer books that transcends its subject matter. Why? Because it can make you a better programmer. While some of the credit can rightly be given to unit testing and Test-Driven Development in general, Rainsberger's book makes you /see/ better ways to write and refactor your code. The breadth and depth of examples is astonishing--he convincingly shatters "but it's too hard to test that" arguments with well-researched, non-trivial examples. In fact, I'd say that this is almost a better J2EE tutorial than most books about J2EE proper.

I'm withholding a star for one reason: the book doesn't cover GUI testing tools like Jemmy, JFCUnit, or Abbot/Costello. These JUnit extensions are ripe for a book with this depth; it's just too bad that this couldn't be that book. Other than that, I find that I turn to Rainsberger's book far more often than any other testing book or online reference.

Required reading for using Java+J2EE+JUnit in the real world, 2005-11-19, Rating: 4.

This review also appears on StickyMinds at http://www.stickyminds.com/s.asp?F=S767_BOOK_4

JUnit Recipes is a comprehensive tome of practical methods and techniques for the opensource JUnit tool to develop automated unit-tests for Java/J2EE applications. The book is split into four parts: Building Blocks, Testing J2EE, Additional JUnit Techniques, and Appendices. The Building Blocks cover the basics of using JUnit to create basic tests, organize and manage test suites and test data, running JUnit tests and reporting the results. It even 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 (including code of course), some short and sweet essays on testing, and a modest recommended reading list.

The 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 Spys. The book's coverage is very comprehensive and touches on many other popular Java/Enterprise projects and frameworks such as Struts, JBOSS, Prevayler, XDoclet, Tomcat, XPath, XMLUnit, HTTPUnit, Ant, Jakarta, 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 book also goes into considerable detail, with working code examples, to spell out exactly how to perform and apply the techniques it describes.

The book's primary audience is Java developers. Java Tester's will still find some good nuggets of information but it's quite clear that Java programmers and developers are the target audience. This isn't some high-level theoretical book mostly of concepts and ideas. This is an imminently pragmatic guide that not only conveys a great deal of highly practical wisdom but also clearly and comprehensively walks you through the explanations and the code to accomplish and apply the techniques it describes. The book is also 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 and using JUnit and on using JUnit to tackle a number of basic challenges with unit-testing Java and J2EE code. JUnit Recipes has some overlapping material but pretty much "picks up" where "JUnit in Action" leaves off, and JUnit Recipes goes into much more breadth and depth of coverage of JUnit methods, practices and techniques and use with other Java projects and frameworks.

I would say JUnit Recipes should probably be required reading for anyone attempting to use Java, J2EE and JUnit in the real-world.

See more reviews on Amazon.com...