aspose file tools*
The moose likes Testing and the fly likes dbunit Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » Testing
Bookmark "dbunit" Watch "dbunit" New topic
Author

dbunit

Peter Straw
Ranch Hand

Joined: Jan 08, 2002
Posts: 79
Once I've managed to populate a database with data from an xml file using dbunit and run a test, how is it then possible to use dbunit to modify the data so that I can run another test? I don't want to use jdbc and it would be good if I could change the data without reading in another xml file.
Thanks.
Lasse Koskela
author
Sheriff

Joined: Jan 23, 2002
Posts: 11962
    
    5
The whole idea of dbUnit is that before each test, dbUnit puts your database in the same, known state so that your tests stay independent. The data in your database is part of your test fixture. If you have two test cases that each require a different fixture, you should split those two tests into two separate test classes, and so forth.


Author of Test Driven (2007) and Effective Unit Testing (2013) [Blog] [HowToAskQuestionsOnJavaRanch]
Lasse Koskela
author
Sheriff

Joined: Jan 23, 2002
Posts: 11962
    
    5
Coming back to this... You might consider driving the database-connected tests from an Ant script and use the DbUnit Ant task to set up the database in a known state before/after certain sets of JUnit tests.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: dbunit