gpt4 book ai didi

grails - 与其他集成测试一起运行时,Spock 集成测试失败 - 使用集成 :spock 单独成功

转载 作者:行者123 更新时间:2023-12-01 15:32:54 25 4
gpt4 key购买 nike

我正在为 grails 2.1.1 应用程序的一组现有测试添加第一个 spock 集成测试。使用以下方法运行时,测试运行和测试通过:

grails test-app integration:spock CreditServiceSpec

(是的,一切都在默认包中 - 修复这是大量不会被批准的工作......在技术债务下归档。)

但是,当我运行所有测试(grails test-app)、单元测试通过、spock 单元测试通过、集成测试通过时,但我遇到以下 spock 集成失败:

| Completed 818 integration tests, 0 failed in 104001ms | Running 1 spock test... | Failure: CreditServiceSpec | groovy.lang.GroovyRuntimeException: failed to invoke constructor: public org.codehaus.groovy.grails.test.support.GrailsTestAutowirer(org.springframework.context.ApplicationContext) with arguments: [] reason: java.lang.IllegalArgumentException at grails.plugin.spock.IntegrationSpec.$spock_initializeSharedFields(IntegrationSpec.groovy:33) | Completed 0 spock test, 0 failed in 33ms | Tests PASSED - view reports in /Users/*/projects/GrailsPlugins/DomainServices/target/test-reports



无论是运行我构建的完整测试还是以下非常精简的示例,我都会得到完全相同的异常:
import grails.plugin.spock.IntegrationSpec

class CreditServiceSpec extends IntegrationSpec {
def setup() {}
def cleanup() {}

public void "sample"() {
setup:"Nothing to do here."

expect:"This is the truest of truths..."
true == true
}
}

我确实打开了 IntegrationSpec 并查看了第 33 行:
@Shared private autowirer = new GrailsTestAutowirer(applicationContext)

但是确定如何/为什么没有正确传递 applicationContext 超出了我的范围,也许,这就是我的问题的重点。

有没有人遇到过这种行为并找到了一种方法来让 spock 集成与其他测试一起玩?谢谢。

最佳答案

看起来 Grails 2.1.1 有 several issues在集成范围内使用 Spock 测试。 Jeff's commentPeter's特别是听起来像您遇到的问题;基本上 ApplicationHolder 为空或空列表。

父任务将 Grails 2.2.5 列为修复版本。您是否有机会升级到那个(或什至更高版本)并查看问题是否仍然存在?

也有过简单的 grails clean has fixed issues like this .

关于grails - 与其他集成测试一起运行时,Spock 集成测试失败 - 使用集成 :spock 单独成功,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19659827/

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