我有一个测试,其中gsp使用了Asset Pipeline标签assetPath,在grails 2中我没有问题,但在grails 3中我得到了一个org.grails.taglib.GrailsTagException: [SOME_GSP.gsp:184] Error executing tag <g:form>: Error evaluating expression [assetPath(src: 'SOME_PDF.pdf')] on line [60]: No signature of method: SOME_GSP_gsp.assetPath() is applicable for argument types: (java.util.LinkedHashMap) values: [[src:SOME_PDF.pdf]]
Grails 3.1.6
示例测试文件:
@TestMixin(GroovyPageUnitTestMixin)
class SomeTests extends Specification {
void "ssn is not returned to the SOME_GSP page"() {
given:
def cmd = new commandObject(SOME_FIELD: 'data')
when:
def renderedView = render(view: 'SOME_GSP', model: [cmd: cmd])
then:
assert !renderedView.contains('data')
}
}发布于 2016-10-17 22:54:49
原来我需要模拟某些类:
@Mock([AssetsTagLib, AssetMethodTagLib, AssetProcessorService])为了获得要解析的类,我需要向build.gradle添加一个testCompile依赖项
testCompile "com.bertramlabs.plugins:asset-pipeline-grails:2.9.4"https://stackoverflow.com/questions/38597805
复制相似问题