If possible you could delete the DB file from the file system on
tearDown and work from an empty DB file which you generate on setUp.
This way you can avoid these side effects.


--- In [EMAIL PROTECTED], "MKlaene" <[EMAIL PROTECTED]> wrote:
>
>
> I'm having some concerns as I write some tests for my DAOs.  My
> concern is that I can't figure out a good way to write these tests
> without relying on other DAO methods.
>
> For example, my employeeDAO might have a createEmployee(Employee
> employee) method and a getEmployeeById(Integer id) method.  Almost
> all of my tests rely on a employee record being pre-populated.  For
> now, I'm calling my createEmployee DAO method in setup() so every
> test has it.  Then I call the deleteEmployee(Employee employee)
> method in tearDown().  It bothers me somewhat to have to do this as
> I would prefer to only call those methods within their
corresponding
> test methods. 
>
> I've looked at DBUnit.  The problem here is that I still have to
> populate my bean from the database - then I'm back to calling a DAO
> method like getEmployeeById in every method - an undesirable
> dependency.  Another option I guess would be to have some DAO
> methods used only for testing but this seems overkill.  I'd rather
> use the database during testing too, not mock objects.
>
> So, I guess my questions are:
>
> 1.)Is there a good way to test DAOs in isolation, without relying
on
> other DAO methods?
> 2.)Does it really matter that much anyway if I use other DAO
> methods?  I mean, the goal is for ALL tests to pass anyway.  It can
> be confusing if your testDeleteEmployee method fails due to a
> failure in createEmployee which you have to call first, but I guess
> it wouldn't take long to figure out what really happened.
>
> Any feedback would be appreciated.
> Thanks,
> Mike







Yahoo! Groups Sponsor
ADVERTISEMENT
click here
Web Bug from http://us.adserver.yahoo.com/l?M=294855.5468653.6549235.3001176/D=groups/S=:HM/A=2376776/rand=836322588


Yahoo! Groups Links

Reply via email to