我正在尝试使用build-test-data 插件(v. 2.0.4)在 Grails 2.1.4 应用程序的单元测试中构建测试数据。
该应用程序具有以下域类
class Brochure {
static constraints = {}
static hasMany = [pageTags: PageTag]
}
class PageTag {
static constraints = {
}
static belongsTo = [brochure: Brochure]
}
然后在我的单元测试中,我尝试构建一个PageTag
with
@Build([Brochure, PageTag])
class BrochureTests {
void testSomething() {
PageTag pageTag = PageTag.build()
}
}
但它失败并出现错误
groovy.lang.MissingMethodException:没有方法签名:btd.bug.Brochure.addToPageTags() 适用于参数类型:(btd.bug.PageTag) 值:[btd.bug.PageTag : (unsaved)] 可能的解决方案:getPageTags ()
我的示例看起来与插件文档中显示的完全相同,所以我不知道为什么这不起作用。此处提供了演示该问题的示例应用程序。