jakarta-cactus-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Vincent Massol" <vmas...@pivolis.com>
Subject RE: RE : Always execute a end method on the client-side?
Date Wed, 03 Sep 2003 20:07:44 GMT


> -----Original Message-----
> From: BRUNOT S├ębastien
[mailto:sebastien.brunot.prestataire@cegetel.fr]
> Sent: 03 September 2003 09:49
> To: 'Cactus Users List'
> Subject: RE : Always execute a end method on the client-side?
> 
> >>
> >> My problem is that I set up test data using DBUnit on the client in
> the
> >> begin(WebRequest) method, and then want to clean it up after the
test
> has
> >> run, regardless of it has failed or not. I do not want the DBUnit
> JARs,
> >> test-data etc. transported to the server unless I absolutely _have
> to_. :-
> >> )
> 
> >On that point, my belief is that database cleaning should not be done
as
> it
> is a waste of >time. Why not better set up the database in the correct
> state
> *before* each test? This
> >prevents side effects and is inline with the unit testing methodology
> which
> says that all >tests are independent. It's also clearer for a reader
as he
> will know what data needs to >be set before the test.
> 
> I think that database cleaning after each test is a good thing to do :
as
> a
> unit test doesn't know wich test was run before it, it has to clean
the
> entire database and then set up the entire database if the cleaning is
> done
> in the setUp() method... If you perform the cleaning at the end of the
> test,
> you just have to clean the data you generated during test execution.
It
> might save a lot of time, especially if you intend to run the same
tests
> under different database load conditions !
> 
> Some real life experiences on the subject ? (or maybe we should follow
up
> the thread on a more "generalist" unit testing mailing list ?)

If you want to apply your strategy you'll need to setup the whole
database at least once before all the tests run (possibly in a
TestSetup's setUp() method).

Now, it all depends on how coarse-grained are your tests. If you're
doing functional testing calling and thus testing code that calls and
touches several tables you may find that you have a complex setup to do.
However, if you're talking about unit testing, I've found that my code
under test only tests one or a few tables only and the setup is both
easy and fast.

I guess it also depends on how complex your database model is.

-Vincent


Mime
View raw message