gpt4 book ai didi

unit-testing - 在 grails 2.3.8 中测试通过后出现 ScriptExitException

转载 作者:行者123 更新时间:2023-12-04 05:13:44 24 4
gpt4 key购买 nike

编辑: 我无法再重现此问题。根本原因对我来说仍然是个谜。

在包含 2 个单元测试的非常小的示例项目上运行 grails test-app 时,测试全部通过,但之后我收到一条错误消息:

grails> test-app
| Running without daemon...
...............................................
|Compiling 1 source files
.
|Running 2 unit tests...
|Running 2 unit tests... 1 of 2
|Running 2 unit tests... 2 of 2
|Completed 2 unit tests, 0 failed in 0m 7s
.................
|Tests PASSED - view reports in C:\src\grails238-test\target\test-reports
Picked up _JAVA_OPTIONS: -Duser.home=C:\Users\rmorrise -Xms128M -Xmx512M -XX:PermSize=128M -XX:MaxPe
rmSize=384M
| Error Error running script test-app: org.codehaus.groovy.grails.cli.ScriptExitException (Use --sta
cktrace to see the full trace)

如果这是我的代码中的错误,任何人都可以提示我要查找的内容吗?

--堆栈跟踪输出和测试规范代码如下。

| Error Error running script test-app --stacktrace: org.codehaus.groovy.grails.cli.ScriptExitExcepti
on (NOTE: Stack trace has been filtered. Use --verbose to see entire trace.)
org.codehaus.groovy.grails.cli.ScriptExitException
at org.codehaus.gant.GantMetaClass.invokeMethod(GantMetaClass.java:133)
at _GrailsTest_groovy$_run_closure1.doCall(_GrailsTest_groovy:98)
at org.codehaus.gant.GantMetaClass.invokeMethod(GantMetaClass.java:133)
at org.codehaus.gant.GantBinding$_initializeGantBinding_closure5_closure16_closure18.doCall(
GantBinding.groovy:185)
at org.codehaus.gant.GantBinding$_initializeGantBinding_closure5_closure16_closure18.doCall(
GantBinding.groovy)
at org.codehaus.gant.GantBinding.withTargetEvent(GantBinding.groovy:90)
at org.codehaus.gant.GantBinding.this$4$withTargetEvent(GantBinding.groovy)
at org.codehaus.gant.GantBinding$_initializeGantBinding_closure5_closure16.doCall(GantBindin
g.groovy:185)
at org.codehaus.gant.GantBinding$_initializeGantBinding_closure5_closure16.doCall(GantBindin
g.groovy)
at org.codehaus.gant.GantMetaClass.invokeMethod(GantMetaClass.java:133)
at TestApp$_run_closure1.doCall(TestApp.groovy:32)
at org.codehaus.gant.GantMetaClass.invokeMethod(GantMetaClass.java:133)
at org.codehaus.gant.GantBinding$_initializeGantBinding_closure5_closure16_closure18.doCall(
GantBinding.groovy:185)
at org.codehaus.gant.GantBinding$_initializeGantBinding_closure5_closure16_closure18.doCall(
GantBinding.groovy)
at org.codehaus.gant.GantBinding.withTargetEvent(GantBinding.groovy:90)
at org.codehaus.gant.GantBinding.this$4$withTargetEvent(GantBinding.groovy)
at org.codehaus.gant.GantBinding$_initializeGantBinding_closure5_closure16.doCall(GantBindin
g.groovy:185)
at org.codehaus.gant.GantBinding$_initializeGantBinding_closure5_closure16.doCall(GantBindin
g.groovy)
at gant.Gant$_dispatch_closure5.doCall(Gant.groovy:381)
at gant.Gant$_dispatch_closure7.doCall(Gant.groovy:415)
at gant.Gant$_dispatch_closure7.doCall(Gant.groovy)
at gant.Gant.withBuildListeners(Gant.groovy:427)
at gant.Gant.this$2$withBuildListeners(Gant.groovy)
at gant.Gant$this$2$withBuildListeners$2.callCurrent(Unknown Source)
at gant.Gant$this$2$withBuildListeners$2.callCurrent(Unknown Source)
at gant.Gant.dispatch(Gant.groovy:415)
at gant.Gant.this$2$dispatch(Gant.groovy)
at gant.Gant.invokeMethod(Gant.groovy)
at gant.Gant.executeTargets(Gant.groovy:591)
at gant.Gant.executeTargets(Gant.groovy:590)
| Error Error running script test-app --stacktrace: org.codehaus.groovy.grails.cli.ScriptExitExcepti
on

这是我的两个测试规范:

图书规范:

package grails238.test

import grails.test.mixin.TestFor
import spock.lang.Specification

/**
* See the API for {@link grails.test.mixin.domain.DomainClassUnitTestMixin} for usage instructions
*/
@TestFor(Book)
class BookSpec extends Specification {

def setup() {
}

def cleanup() {
}

void "test foo"() {
when:
domain.title = "Foo"
then:
domain.title == "Foo"
}
}

BookControllerSpec:

package grails238.test

import grails.test.mixin.TestFor
import spock.lang.Specification

/**
* See the API for {@link grails.test.mixin.web.ControllerUnitTestMixin} for usage instructions
*/
@TestFor(BookController)
class BookControllerSpec extends Specification {

def setup() {
}

def cleanup() {
}

void "test foo"() {
when: "index"
controller.index()
then: "expect nothing"
controller.response.contentAsString == "Hello World"

}
}

最佳答案

对于 Windows 上的 grails 2.3.5 和 2.3.8,可以通过编辑“scripts/_GrailsTest.groovy”来解决这个问题。

第 97 行:

if(exitCode != null) {

应替换为

if(exitCode != null && exitCode != 0) {

引用: https://jira.grails.org/browse/GRAILS-10809

关于unit-testing - 在 grails 2.3.8 中测试通过后出现 ScriptExitException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23704745/

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