2011-02-28 55 views
0

我試圖創建一個UrlMappingsTest我的Grails項目,並且我得到以下異常:UrlMappingsTests - 無法加載測試類型「集成」中的類?

java.lang.RuntimeException: Could not load class in test type 'integration' 
     at gant.Gant$_dispatch_closure5.doCall(Gant.groovy:391) 
     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:590) 
     at gant.Gant.executeTargets(Gant.groovy:589) 

我的類是相當簡單的,我試圖效仿的榜樣。這是怎麼回事?

import grails.test.GrailsUrlMappingsTestCase 

class UrlMappingTests extends GrailsUrlMappingsTestCase { 
// static mappings = UrlMappings 

    void testForwardingUrls(){ 
    assertForwardUrlMapping("/rest/users/stefan/files", controller: "file", action: "allFiles"); 
    } 
} 

與靜態行註釋掉,我得到

[groovyc] You attempted to reference a variable in the binding or an instance variable from a static context. 
    [groovyc] You misspelled a classname or statically imported field. Please check the spelling. 
    [groovyc] You attempted to use a method 'UrlMappings' but left out brackets in a place not allowed by the grammar. 
    [groovyc] @ line 7, column 21. 
    [groovyc]  static mappings = UrlMappings 
    [groovyc]  

      ^

回答

0

如果你看一下sourceGrailsUrlMappingsTestCase你會看到(你也許懷疑)static mappings = UrlMappings是不需要的,因爲它如果你不指定一個靜態映射變量,默認情況下。當您將該行註釋掉時,您是否在java.lang.RuntimeException: Could not load class in test type 'integration'下獲得了嵌套異常?發佈完整的堆棧跟蹤,它應該工作。你使用的是什麼版本的grails?

+0

我得到沒有找到我的時候沒有運行的類。我正在使用1.3.7 – 2011-03-02 14:48:26

+0

嗯沒關係我正在測試我的1.3.6,它的工作。你可以發佈完整的堆棧跟蹤嗎? – Melv 2011-03-02 21:36:48

+0

我開始了一個新項目,在1.3.7中失敗了。我懷疑這是迴歸。 – 2011-03-04 17:44:51

相關問題