ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Bostjan Dolenc <bostjan.dol...@marand.si>
Subject Re: Dao unit testing?
Date Thu, 10 Feb 2005 15:53:52 GMT
Nathan Maves wrote:

> I have been trying for two day to get DBunit to work with only partial 
> success.  The support for this project is nonexistent.  Anyone know of a 
> more supported project or have any experience with this one?  How do 
> most of you test your database layer?
I wrote tests for my Session Beans, but one may think of them as DAOs 
(they don't do much more DB). Basically I created some scenarios, such a 
s writing of a "full" (all properties non-null) object, write and then 
read back, write N objects and check if one gets N objects back...

To set up the (clean) initial state, I used the session bean facade. 
Fortunately all my data is partitioned by user (one user must not access 
data of another one), so I already had methods in the beans to delete 
all data (or all "objects" of certain kind) for a user. I encapsulated 
initial data creation into separate classes - one class for certain state.

As you can see, nothing special. As long as you can avoid 1+N deletes 
and test data is sufficiently small (and your code used to write it is 
fast), this works. If you need a complex initial state, this approach is 
too slow.

All tests take a bit more than 3 minutes and contain around 50 test 
methods. But note that one test is a speed test which takes about a minute.


View raw message