问题
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