我找到了Peter Ledbrook的artice测试Grails脚本(http://www.cacoethes.co.uk/blog/groovyandgrails/testing-your-grails-scripts)。 '好',我想,我们走吧。但我花了很多年(没有互联网接入)没有得到它的工作。我正在使用Grails 2.1.1和GGTS 3.1Grails我无法测试脚本的工作 - 退出代码总是1
我试图运行他的hello-world脚本。当我将它作为命令调用时,它就起作用。但是,当我尝试从test \ cli中的测试类调用它时,退出代码始终为1.我已经为测试(和脚本)添加了一些println语句。从我所看到的,脚本永远不会被调用(也不会提供像'战争'这样的脚本)。这里开始我的测试类:
class HelloWorldTests extends AbstractCliTestCase {
void testDefault() {
println "work dir: "+System.getProperty("grails.home") //cli.work.dir")
println "about to call script"
execute(['hello-world']) // Pass parameters in the list
println "called script"
int exitCode = waitForProcess()
println "exit code "+exitCode
println "output: "+super.getOutput()
if (exitCode != 0) {
println output
}
assertEquals 0, exitCode
从println语句的输出是:
work dir: C:\Apps\GGTS310\grails-2.1.1\
about to call script
called script
exit code 1
output:
从我能想出的形式看AbstractCliTestCase的代码,也应该是在'输出',但没有。
帮助感激地接受
约翰
既然我的笔记本电脑是网络连接的,那么我会在'输出'中找到一些东西。我想我需要为测试设置一些虚拟机参数,但是如何? 输出:VM初始化期间发生错误 无法为请求的堆大小的并行垃圾回收分配位图。 错误:无法创建Java虚拟机。 错误:发生了致命异常。程序将会退出。 BTW:这是Win 64位64位GGTS和64位Jdk 1.7.09 – 2013-02-14 14:38:35