[[http://www.dbunit.org/|DbUnit]] is a very handy tool for inserting test data into your database or confirming data after your tests. Sometimes, however, you run into gotchas. * [[http://www.systemmobile.com/wp/?p=109|Inserting timestamps]] -- They have to be formatted as "`yyyy-MM-dd HH:mm:ss.fffffffff`" * [[http://idiacomputing.com/moin/PrimaryKeyGeneration#head-d7949da7a424b68c0ae6279e11b7e8718331321e|autonumbered primary keys]] -- you've got to let DbUnit generate the keys. * Some columns not populating? You probably didn't specify a DTD and those columns weren't mentioned in the data for the first row. See the [[http://dbunit.sourceforge.net/components.html#flatxmldataset|warning]] and [[http://dbunit.sourceforge.net/faq.html#generatedtd|instructions]] for generating a DTD. I temporarily added a test as a quick-and-dirty way of executing this: {{{ public void testExportDtd() throws Exception { IDatabaseConnection connection = getConnection(); FlatDtdDataSet.write(connection.createDataSet(), new FileOutputStream(XML_DATASET_ROOT+"test.dtd")); } }}} * Don't forget to add the DTD declaration to the top of your XML file: `` Unfortunately, DbUnit interprets this path from the location of execution, while the XML validator of MyEclipse interprets the path relative to the location of the XML file.