Unit testing 单元测试grails标签

Unit testing 单元测试grails标签,unit-testing,grails,groovy,tags,taglib,Unit Testing,Grails,Groovy,Tags,Taglib,我写了一个Grails标记,它只是一个非常薄的包装 package.com.example 类MyTagLib{ def listTrees={attrs-> List allTrees=getMandatoryAttributeValue(attrs,“trees”) out您必须模拟正在使用的grails标记库,并通过元类机制注入它 protected void setUp() { super.setUp() mockTagLib(FormTagLib) def g

我写了一个Grails标记,它只是一个非常薄的包装

package.com.example
类MyTagLib{
def listTrees={attrs->
List allTrees=getMandatoryAttributeValue(attrs,“trees”)

out您必须模拟正在使用的grails标记库,并通过元类机制注入它

protected void setUp() {
    super.setUp()
    mockTagLib(FormTagLib)
    def g = new FormTagLib()
    tagLib.metaClass.g = g
}

问题是FormTagLib的某些属性没有正确模拟。请参阅
protected void setUp() {
    super.setUp()
    mockTagLib(FormTagLib)
    def g = new FormTagLib()
    tagLib.metaClass.g = g
}