users
[Top] [All Lists]

Re: [cinjug-users] DbUnit and Hibernate

To: "users@xxxxxxxxxx" <users@xxxxxxxxxx>
Subject: Re: [cinjug-users] DbUnit and Hibernate
From: Rob Keefer <rbkeefer@xxxxxxxxx>
Date: Tue, 8 Aug 2006 11:40:53 -0700 (PDT)
Delivered-to: mailing list users@cinjug.org
Domainkey-signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; h=Message-ID:Received:Date:From:Reply-To:Subject:To:In-Reply-To:MIME-Version:Content-Type; b=liAVwAM0J+sQGlX6U7S9O5ytInJLuLqcuzv30C42AIDkPD/71ypXT8EiS9vimIkAf4/2VSk2L3HvjNLs0+b17RcEqPDmQT43gHmcw/yNYVOAEfn7WMwZnA72adlpZOUbe5jNTecoZ3SWDV0yT2+wM2vyKFjiGcmS8Iu5oh1Jz+E= ;
In-reply-to: <6a216ba20608081024l6ef985e2t14718413e61f7571@mail.gmail.com>
Mailing-list: contact users-help@cinjug.org; run by ezmlm
Reply-to: Rob Keefer <Rob.Keefer@xxxxxxxxxxxxxxxxxx>
I just want to reinforce Ed's comment a bit...
 
Unit testing of DAOs is difficult because you'd like to have reproducible tests that affect multiple tables, so after each test you need to get the tables back into a known state. What hsqldb buys you is the ability to do this easily.
 
On a project a few years back we had a crap-load of DAO tests that took 16 hours to run. We had them organized into three categories Select oriented query tests (so data wasn't altered at all), CRUD oriented tests (each test was able to reset the data to a known state after it completed), and then the transaction oriented tests. We tried a number of schemes to update the database between transaction oriented tests, but none worked very well.
 
So, even with some of the drawbacks this export to hsqldb method has, it is easily the best method we have found to do these kinds of tests, and we have the scars to show we've tried plenty of other methods.
 
- Rob


 
----- Original Message ----
From: Edward Sumerfield <esumerfd@xxxxxxxxx>
To: "users@xxxxxxxxxx" <users@xxxxxxxxxx>
Sent: Tuesday, August 8, 2006 1:24:18 PM
Subject: Re: [cinjug-users] DbUnit and Hibernate

DBUnit rocks. It gives you data exporting and importing to a few different formats. I use Excel and XML format. I export data from an Oracle database and import into hsqldb between each test. Very fast and fairly simple to use.

The toughest problem is managing load dependencies. Each exported table and row must not break the foreign keys.

Oracle allows us to generate a list of tables in foreign key dependent order. It doesn't solve the problem of self-referencing tables and the row sequence though.

Additionally, since you are likley not exporting the entire database you may miss some required dependencies so there is usually some data patching that is required after the export to ensure that the data can be re-loaded correctly.

Make sure that you allow the export to include tables from a sub-dependent tree. I have never been able to fix the dependencies for an entire schema.


On 8/8/06, twcrone@xxxxxxxxxxxxx <twcrone@xxxxxxxxxxxxx> wrote:

In the past I have not built very good tests for my Hibernate DAO's.  Typically write a main method that tests the CRUD operations but never put it somewhere that others can easily use it or it can easily be run as a test suite.  I have heard of something called DBUNIT that I plan to look into.  Any other suggestions?

BTW...NFJS conference this weekend was GREAT!!!

- Todd

 




--
Ed

<Prev in Thread] Current Thread [Next in Thread>