I've been trying to get some
test infrastructure setup for a project using both DbUnit and Hibernate's hbm2ddl.auto setting.
In an earlier project with hbm2ddl.auto (instead using hand-coded DDL scripts), I had a working setup using DbUnit's CLEAN_INSERT option in test setUps, and no-ops in tear-downs. This was great as it allowed manual inspection of the test database after the test failed (when only that test was run, of course).
With hbm2ddl.auto, I get foreign key exceptions during the CLEAN_INSERT setUp. I'm assuming I didn't see these in the earlier case because I had enough "on delete cascade" claues, and just got lucky with the order that DbUnit was delete things. (Since i do have some on delete restricts in there, I would beleive I could hit the same problem on that project at some point in the future)
(Yes I know that DbUnit deletes in reverse order when the delete happens in the teardown, but DbUnit can't know an order in the CLEAN_INSERT case since that would require the test to know which test ran before, in order to figure out (via some unknown channel) which xml file was used to populate the database.)
Has anyone come across a good approach for using DbUnit and hbm2ddl.auto?