【问题标题】:TestDataConfig.groovy not found, build-test-data plugin proceeding without config file未找到 TestDataConfig.groovy,build-test-data 插件在没有配置文件的情况下继续进行
【发布时间】:2013-08-22 21:35:01
【问题描述】:

在单元测试中包含 Mixin Build 时出现以下错误:

TestDataConfig.groovy 未找到,build-test-data 插件在没有配置文件的情况下继续进行

它在集成测试中就像魅力一样,但不是单元测试的一部分。我的意思是,'build' 插件在单元测试中自己工作,但 'TestDataConfig' 没有填充默认值

谢谢

【问题讨论】:

    标签: grails grails-plugin


    【解决方案1】:

    首先,您应该从 BuildConfig.groovy 中的 build-test-data 验证版本

    测试“:build-test-data:2.0.3”

    其次,检查您的测试。如果你想构建你需要的对象:

    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()
        }
    }
    

    第三,检查域约束,当你构建两个实例时,你可能会有一些属性验证,比如唯一性失败。您需要在代码中设置该属性:

    def tc1 = TestingClass.build(uniqueProperty: 'unique')
    def tc2 = TestingClass.build(uniqueProperty: 'special')
    

    【讨论】:

    • 感谢您的回复。我不确定发生了什么,但它现在似乎正在运行......当我玩得更多时,我会弄清楚发生了什么并准确发布存在的问题。再次感谢
    • 同意下面的评论 - 应该是 test 依赖而不是编译依赖,确定吗?
    • 这是真的。我只是从插件页面粘贴它。答案已编辑。
    【解决方案2】:

    我猜依赖应该是:

    test ":build-test-data:2.0.3"
    

    既然只是用于测试,对吧?

    【讨论】:

      猜你喜欢
      • 2019-08-03
      • 2011-02-10
      • 1970-01-01
      • 2011-05-16
      • 2013-04-12
      • 2017-07-21
      • 1970-01-01
      • 1970-01-01
      • 2021-05-20
      相关资源
      最近更新 更多