当前位置: 首页 > 知识库问答 >
问题:

grails 2.3 spock集成测试未发现WebApplicationContext错误

陶星渊
2023-03-14

我刚刚将一个现有的应用程序从Grails 2.2.4升级到2.3.0。从那以后,所有的spock集成测试都被打破了。我得到的错误消息如下所示。运行单元测试或run-app没有问题。谢谢预付费的任何建议。

java prettyprint-override">| Error Fatal error running tests: No WebApplicationContext found: no ContextLoaderListener registered? (NOTE: Stack trace has been filtered. Use --verbose to see entire trace.)
java.lang.IllegalStateException: No WebApplicationContext found: no ContextLoaderListener registered?
    at org.springframework.web.context.support.WebApplicationContextUtils.getRequiredWebApplicationContext(WebApplicationContextUtils.java:90)
    at grails.util.Holders.getApplicationContext(Holders.java:78)
    at _GrailsTest_groovy$_run_closure1.doCall(_GrailsTest_groovy:95)
    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(GantBinding.groovy:185)
    at org.codehaus.gant.GantBinding$_initializeGantBinding_closure5_closure16.doCall(GantBinding.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(GantBinding.groovy:185)
    at org.codehaus.gant.GantBinding$_initializeGantBinding_closure5_closure16.doCall(GantBinding.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.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 Fatal error running tests: No WebApplicationContext found: no ContextLoaderListener registered?

共有1个答案

漆雕宏浚
2023-03-14

您不再需要将Spock插件添加到grails>=2.3的项目中。

只需像以前一样创建Spock规范,它们将作为单元测试运行。事实上,不要安装Spock插件,否则您的规范将运行两次,并可能失败。这也意味着spock测试类型不再存在。

规范和JUnit测试现在以相同的类型运行。

 类似资料:
  • 英文原文:http://emberjs.com/guides/testing/integration/ 集成测试通常用来测试应用中得重要工作流。集成测试用来模拟用户交互和确认交互结果。 设置 为了对Ember应用进行集成测试,需要在测试框架中运行应用。首先需要将根元素(root element)设置为任意一个已知将存在的元素。如果根元素在测试运行时可见的话,这对测试驱动开发非常有用,带来的帮助非常

  • 主要内容:集成测试背后的原因,集成测试技术,集成测试方法,集成测试指南集成测试是单元测试后软件测试过程的第二个层次。在此测试中,软件的单元或单个组件在组中进行测试。集成测试级别的重点是在集成组件或单元之间交互时暴露缺陷。 单元测试使用模块进行测试,这些模块在集成测试中进行组合和测试。该软件使用许多软件模块开发,这些软件模块由不同的编码器或程序员编码。集成测试的目标是检查所有模块之间通信的正确性。 集成测试背后的原因 虽然软件应用程序的所有模块已经在单元测试中进行了测

  • 设计 集成测试包括 3 个模块:测试用例、测试环境以及测试引擎。 测试用例 用于定义待测试的 SQL 以及测试结果的断言数据。 每个用例定义一条 SQL,SQL 可定义多种数据库执行类型。 测试环境 用于搭建运行测试用例的数据库和 ShardingSphere-Proxy 环境。 环境又具体分为环境准备方式,数据库类型和场景。 环境准备方式分为 Native 和 Docker,未来还将增加 Emb

  • 我正在升级我们现有的解决方案。NET 4.6.1,并且在服务器构建期间无法运行我们的单元测试。在本地,它们按预期运行,并将框架版本翻转回。Net 4.5.1使它们在服务器上再次运行。 我得到以下错误: 未发现测试。确保安装的测试发现者 我在一个更简单的设置中重现了该问题: 使用一个C#单元测试项目和两个测试(一个失败,一个通过)的解决方案

  • 你好我和Gradle和IntelliJ有个问题不知从哪里冒出来。一切都在运转,但有一天它停止运转了。我指的是在IntelliJ中与Gradle的任何互动。我有Spring Boot应用程序Gradle 6.7。当没有的时候。根目录中的gradle目录,一切正常。如果目录存在,我会得到 主类名尚未配置,无法解析 对于gradle build或 未收到测试事件 对于gradle测试。如果我删除. gr

  • 我有一个用selenium进行单元测试和集成测试的项目。 当我用IntelliJ执行cucumber集成测试时,它工作得很好,您可以看到: 用Intellij执行cucumber集成测试 但是,当我执行mvn集成测试时,似乎没有发现任何联调: 故障保护输出 我定义了以下POM: > 文件夹结构是文件夹结构 mvn集成-测试输出https://drive . Google . com/file/d/