O'Reilly logo

Java EE 6 Cookbook for Securing, Tuning, and Extending Enterprise Applications by Mick Knutson

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Testing JPA with DBUnit

In Chapter 2, Enterprise Persistence, we touched on some examples where we were testing our JPA examples. In this recipe, we will take a step-by-step approach on how to use JUnit and DBUnit in your Java EE application. First, I want to review each tool, and the benefits it will provide for this recipe.

The JUnit lifecyle is a fixed series of method calls to ensure consistency when running unit tests. In the following screenshot, we can see the lifecycle that BDUnit and any other unit tests will follow:

Testing JPA with DBUnit

The lifecycle of all unit test classes is exactly the same. You can perform processing before and after the class is created, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required