2011-02-28 64 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

相关问题