This little extension to DbUnit allows you to write the test data using Groovy lists and maps rather than XML or Excel. That way you can keep your test data in the same file as your db integration test, which will be easier to grok and maintain.
GroovyDataset
is the DbUnit extension that you need to put in your project. GroovyDatasetTest
is the unit test for it. UserIntegrationTest
is an example, where the "data" attribute is the test data that is inserted into the database. (In real life, you'd create a superclass and move the SessionFactory, the definition of the data field, the setup() method, etc. there).
This was all described in a blog post:
http://www.jroller.com/kenwdelong/entry/groovy_based_dbdeploy_tests
For how to use it, see the UserIntegrationTest below. You can specify the data for the test in a List of Maps