Navigation Menu

Skip to content

Installation

Aaron edited this page Jan 7, 2018 · 13 revisions

Grails 3.3.x and Later

See new documentation at: http://longwa.github.io/build-test-data/index

Grails 3.0.x to 3.2.x

Add testCompile "org.grails.plugins:build-test-data:3.0.1" to build.gradle

Grails 2.4.x and 2.5.x

Add test ":build-test-data:2.4.0" to grails-app/conf/BuildConfig.groovy


Now all of your domain classes implement the BuildTestDataEntity trait and have a static build() method that automatically generates a valid instance and saves it to the database. You can start using it in your integration tests like this without any additional configuration:

    def author = Author.build()

Most domain objects should be able to be persisted without passing any parameters to build().

For ones that can't be, or if you want to have finer control over the kind of data that they get injected with, there is a config file that gets installed at grails-app/conf/TestDataConfig.groovy. See the TestDataConfig page for more information about the kind of control that you have over how data is automatically constructed.

See the Basic Usage page for additional quick start information.