0

我想在每次测试运行后执行一些额外的脚本步骤。所以基本上,我想在 grails 中创建一个新脚本

  • 首先调用标准test-app functional:webtest -baseUrl=http://example.com
  • 之后运行某种清理脚本

现在我想知道如何test-app从我的脚本中调用脚本......

4

2 回答 2

3

此示例显示了执行此操作的常用方法:

scriptEnv = "test"

includeTargets << grailsScript("_GrailsInit")
includeTargets << grailsScript("_GrailsClean")
includeTargets << grailsScript("_GrailsTest")


target(main: "Testing app (unit coverage)") {
    echo "Testing app (unit coverage)"

    argsMap << ["unit":'']
    argsMap << ["coverage":'']
    phasesToRun = ['unit']

    allTests()
}

setDefaultTarget(main)

该行grailsScript("_GrailsInit")可以解决问题,并将 grails 脚本的目标包含在自己的目标中。

你可以看看这个http://grails.org/doc/latest/guide/commandLine.html#creatingGantScripts

于 2013-07-26T10:54:55.103 回答
1

您需要像这样使用 execute.shell 命令:

includeTool << gant.tools.Execute

target(main: "Run script") {
    execute.shell("grails test-app functional:webtest -baseUrl=http://example.com")
    //Proceed with cleanup code here...
}

有关详细信息,请参阅http://gant.codehaus.org/Execute+Tool

于 2012-08-06T20:26:22.093 回答