Junit Recipes

I’ve had J.B. Rainsberger’s excellent book, JUnit Recipes, for 3-4 days now, and have been taking a look at it whenever I feel like taking a break for a few minutes.

This is a really good book, in ‘recipe’ format, that shows examples for using JUnit to handle most types of unit or integration testing concerns, either with JUnit alone, or with addons like EasyMock, Cactus, DBUnit, etc. I’m a big TDD advocate, so I know a decent amount of this stuff already, and given enough time can generally handle new testing problems I come across, but there’s still a lot of interesting stuff and fresh approaches here for me to look at, and the recipe format lends itself very nicely to getting a specific answer for a specific problem, and saving time in the process.

Rainsberger’s been a fixture in the JUnit community for years, and this book really shows his experience.

 

3 responses

  1. Anonymous says:


    there is a book named junit in action,is it worth reading?


  2. I don’t have JUnit in action, although I’ve skimmed through it in the past. I think it’s also a good book. I would say JUnit in Action is better for soembody who’s not done any or much testing at all, and needs to be lead into the subject, while JUnit Recipes, given the cookbook format, is more focused on people who know the “why” and some of the “how”, but want to know a lot more of the how.

  3. Igor G. says:


    Hello,
    I have junit-4.5 installed in my D: drive. I have set it on my classpath environment variable. When issuing the command java –classpath junit.jar;. junit.textui.TestRunner junit.tests.AllTests I get this error:

    Exception in thread “main” java.lang.NoClassDefFoundError: junit/textui/TestRunner
    Caused by: java.lang.ClassNotFoundException: junit.textui.TestRunner
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClassInternal(Unknown Source)
    Could not find the main class: junit.textui.TestRunner. Program will exit.

    Any ideas?

Leave a Reply