The most useful unit tests are those that reflect the data that you expect or see in practice. Pumping your circuit full of random bits does not replace carefully processed test data. Since @McWafflestix suggested mysqldump is a useful tool, but if you want something simpler, consider using LOAD DATA with INFILE , which populates a table from CSV,
Some other things to think about:
- Test the database in a known state. Wrap all the tests of the database interaction block in transactions that are always rolled back.
- dbunit, .
Java, dbUnit :
- XML API-, .
- . , , , . , (.. ).