Search code examples
javagrailsgroovydbunit

Is the proper equivelent to DBUnit in Grails Bootstrap.groovy?


I used to use DBUnit to populate my database with classes/records expected by my Unit tests, and I noticed that they do sort of the same thing using Boostrap.groovy in Grails, but I am wondering if this is the kosher way of doing this in Grails.

Is it better just to setup DBUnit within Grails? Or does Grails have it's own way of doing this?


Solution

  • I wouldn't recommend Bootstrap.groovy for loading test data. It's likely to become unwieldy, particularly if you want to use different datasets for different tests. There are a number of DBUnit Grails plugins that you could use to simplify integrating DBUnit into a Grails app (though you can also just use the JAR directly).

    There are also some plugins that provide Grails-specific ways of loading test data. The Fixtures plugin seems to be one of the most popular.