2013-10-11 35 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後,一切工作都在之前。

相關問題