2

使用 Grails 2.2.3

我将把我的测试资源保存在 test/resources 目录中。想用它扩展测试类路径。在 BuildConfig.groovy 我添加了这一行:

grailsSettings.testDependencies.add new File("${basedir}/test/resources")

之后grails test-app unit:失败:

_GrailsClasspath_groovy: 17: unable to resolve class     org.codehaus.groovy.grails.compiler.GrailsProjectCompiler
 @ line 17, column 1.

如果我注释掉这一行,异常就消失了。

确保此代码在 Grails 1.3.2 中有效

更新 1

尝试升级到 Grails 2.2.4。同样的问题

更新 2

这是完整的堆栈跟踪

| Error Error executing script TestApp: org/codehaus/groovy/grails/compiler/GrailsProjectCompiler (NOTE: Stack trace has been filtered. Use --verbose to see entire trace.)
java.lang.NoClassDefFoundError: org/codehaus/groovy/grails/compiler/GrailsProjectCompiler
at _GrailsClasspath_groovy.run(_GrailsClasspath_groovy:36)
at _GrailsClasspath_groovy$run.call(Unknown Source)
at _GrailsEvents_groovy$run.call(Unknown Source)
at org.codehaus.gant.IncludeTargets.leftShift(IncludeTargets.groovy:59)
at org.codehaus.gant.IncludeTargets$leftShift.call(Unknown Source)
at _GrailsEvents_groovy.run(_GrailsEvents_groovy:32)
at _GrailsEvents_groovy$run.call(Unknown Source)
at _GrailsClean_groovy$run.call(Unknown Source)
at org.codehaus.gant.IncludeTargets.leftShift(IncludeTargets.groovy:59)
at org.codehaus.gant.IncludeTargets$leftShift.call(Unknown Source)
at _GrailsClean_groovy.run(_GrailsClean_groovy:29)
at _GrailsClean_groovy$run.call(Unknown Source)
at org.codehaus.gant.IncludeTargets.leftShift(IncludeTargets.groovy:59)
at org.codehaus.gant.IncludeTargets$leftShift.call(Unknown Source)
at TestApp.run(TestApp.groovy:24)
at TestApp$run.call(Unknown Source)
at gant.Gant.prepareTargets(Gant.groovy:607)
Caused by: java.lang.ClassNotFoundException: org.codehaus.groovy.grails.compiler.GrailsProjectCompiler
... 17 more
| Error Error executing script TestApp: org/codehaus/groovy/grails/compiler/GrailsProjectCompiler
4

1 回答 1

0

grails.util.BuildSettings您可以在课堂上找到所有构建路径选项。我没有找到任何用于测试资源的特殊文件夹。尝试创建/test/resources文件夹。应该是一样的。

于 2013-12-30T12:12:07.777 回答