Search code examples
grailsintegration-testinggrails-ormh2

How do I create multiple types of test data for a grails integration test using @Build


The first domain works well. But the second domain is not able to have the "build" method

import grails.test.spock.IntegrationSpec
import grails.buildtestdata.mixin.Build

@Build(Domain1)
@Build(Domain2)
class DomainServiceSpec extends IntergrationSpec {

    def "test mock" () {
     Domain1.build(a: a, b: b, c: c) //working fine
     Domain2.build(a: a, b: b, c: c) //"build" method is not recognized
    }
}

Solution

  • @Build([Domain1, Domain2])
    

    I suggest you read the plugin documentation: Unit Test Support