Grails Plugin Build-test-data 0.2.1 Released

| Comments

I’ve just released version 0.2.1 of the build-test-data grails plugin.

The build-test-data plugin makes creating integration test data easy. It decorates your domain objects with a “build” method that will create new domain instances and will automatically populate required fields with data and save it to the database. This enables you to create more maintainable tests where the data you create is targeted specifically at the situations you’re trying to test, without having to go through all of the ceremony of creating the rest of the object graph that you don’t care about.

// creates a new Book instance with all required fields 
// (like the Author that the book belongsTo) populated
def b =   

To learn more about the basics of the build-test-data plugin, see this blog post and check out the Basic Usage and Sample Code wiki pages.

To install, just run the install-plugin grails command (this will also upgrade an existing plugin):

grails install-plugin build-test-data

The 0.2 version of the plugin includes a number of enhancements and bugfixes. Major highlights include:

  • JodaTime support (along with any other persistable class with a zero argument constructor)
  • much easier and more powerful config files (see the TestDataConfig wiki page for details and examples)

Additionally, the code has been cleaned up and refactored to be easier to understand.

See the Release Notes wiki page for full details.

I’d be interested to hear any further feedback on this plugin and other features that people might find useful. I’ve successfully been using it on my current project and it’s been a big help in keeping my tests clean and free from superfluous object construction code, as well as flexible in that it automatically adapts to a changing domain model.