问题
I am getting the following error when including in Mixin Build in unit tests:
TestDataConfig.groovy not found, build-test-data plugin proceeding without config file
it works like charm in the integration tests but not part of unit tests. I mean, 'build' plugin works itself in unit test but the 'TestDataConfig' is not populating default values
Thank You
回答1:
First you should verify the version from build-test-data in your BuildConfig.groovy
test ":build-test-data:2.0.3"
Second, check your test. If you want build objects you need:
import grails.buildtestdata.mixin.Build
...
@TestFor(TestingClass)
@Build([TestingClass, SupportClass, AnotherClass])
class TestingClassTest{
@Test
void testMethod{
def tc1 = TestingClass.build()
def sc1 = SuportClass.build()
def ac1 = AnotherClass.build()
}
}
Third, check the domains constraints, you could have some properties validations like unique that fails when you build two instances. You need set that properties in code:
def tc1 = TestingClass.build(uniqueProperty: 'unique')
def tc2 = TestingClass.build(uniqueProperty: 'special')
回答2:
I guess the dependency should be:
test ":build-test-data:2.0.3"
Since is just used for testing, right?
来源:https://stackoverflow.com/questions/12109136/testdataconfig-groovy-not-found-build-test-data-plugin-proceeding-without-confi