gpt4 book ai didi

grails - 在测试阶段将 `test/resources`目录添加到类路径的正确方法

转载 作者:行者123 更新时间:2023-12-02 14:12:15 26 4
gpt4 key购买 nike

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

最佳答案

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

关于grails - 在测试阶段将 `test/resources`目录添加到类路径的正确方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18053802/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com