TestDataConfig.groovy not found, build-test-data plugin proceeding without config file

本小妞迷上赌 提交于 2019-12-12 01:15:29

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!