在测试阶段将“test / resources”目录添加到classpath的正确方法

时间:2013-08-05 08:36:58

标签: grails

使用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

1 个答案:

答案 0 :(得分:0)

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