2013-10-11 36 views
0

我刚刚升级从Grails的2.2.4现有的应用程序到2.3.0。从那以后,所有的spock集成测试都被破坏了。我得到的错误信息如下所示。运行单元测试或运行应用程序没有问题。感谢提前任何建议。Grails的2.3斯波克集成测试没有发现WebApplicationContext的错误

| 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? 

回答

0

您不再需要的斯波克插件添加到您的项目的Grails> = 2.3。

只需创建斯波克规格之前,他们将被作为运行单元测试。事实上,不要安装Spock插件,否则你的规格将会运行两次并可能失败。这也意味着spock测试类型不再存在。

规格和JUnit测试现在运行为同一类型。

+0

感谢的建议,但我已删除的斯波克依赖和使用来自Grails的2.3.3默认的 – wildleaf

0

确定。我前一阵子想到了。

的原因是我试图在它是在Grails的2.3.2已经规定了嘲笑的ServletContext在集成测试。删除模拟的servletContext后,一切工作都在之前。

相关问题