Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

dbunit

 
Peter Straw
Ranch Hand
Posts: 79
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 11962
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Lasse Koskela
author
Sheriff
Posts: 11962
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic