Gili,
See the dbunit howto[1] page under the section called "Database setup with
your own TestCase subclass.  Since ServletTestCase is already a TestCase
subclass, I've subclassed it further.  Note that I should probably refactor
it to make a DBUnit decorator class. (favor composition over inheritance)
So, I have a class called "ServiceTestCase" which extends ServletTestCase
and contains some helper methods for dbunit.  Then in the setup() and
teardown() methods of my TestClasses (which extend ServiceTestCase) I follow
the steps shown at the dbunit site.  I hope that this makes sense.

Aaron Korver

[1]http://www.dbunit.org/howto.html



> -----Original Message-----
> From: Gili [mailto:[EMAIL PROTECTED]
> Sent: Monday, May 09, 2005 1:31 PM
> To: Cactus Users List
> Subject: Re: Contacting the container from beginXXX()
> 
> 
> 
>       DBUnit looks nice but how would you integrate with it 
> Cactus? Each one 
> requires you to extend a different class and Java doesn't do multiple 
> inheritance.
> 
> Gili
> 
> Korver, Aaron wrote:
> > [snip]
> > 
> >>Why don't you simply fill the database with the right values? 
> >>No need for
> >>any hibernate mapping for this! It can be done in several 
> >>ways, with a SQL
> >>script, by saving a database dump and reloading it, etc.
> > 
> > [snip]
> > 
> > May I also suggest using dbunit[1]?  We have been using 
> this successfully in
> > our environment to setup a fixture and restore a DB to a 
> known state.  If
> > you use it with an in-memory DB you can get pretty good 
> performance.  You
> > just want to only do these tests nightly.  Then mock out 
> your DB and run the
> > "logic" tests using mocks.  Remember that developers are 
> lazy, so if your
> > tests take to long to run, then no one will use them.
> > 
> > [1] www.dbunit.org 
> > 
> > Aaron Korver
> > 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 

Reply via email to