Problems casting a null object with Spock

谁说我不能喝 提交于 2019-12-13 00:17:56

问题


I have a Spock test that fails over two Mac OS X Lion machines, but works over other Linux machines and the Spock Web Console.

I found another related question: Why I get a cannot cast object 'null' error, when testing my controller?

I'm using Grails 2.0.0 and Spock 0.6. Any suggestions? Seems to be a bug

def "casting null object"() {
    expect:
    null as BigDecimal == null
}

| Failure:  casting null object(com.arturoherrero.MySpec)
|  org.codehaus.groovy.runtime.typehandling.GroovyCastException: Cannot cast object 'null' with class 'org.codehaus.groovy.runtime.NullObject' to class 'java.math.BigDecimal'

回答1:


Looks like you've hit this bug with Grails 2.0.0

That says it was fixed for Grails 2.0.2, so maybe an upgrade on one of your machines to check is in order?

Fingers crossed!



来源:https://stackoverflow.com/questions/11756297/problems-casting-a-null-object-with-spock

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!