使用Spock转换null对象的问题 [英] Problems casting a null object with Spock

查看:295
本文介绍了使用Spock转换null对象的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Spock测试,无法通过两台Mac OS X Lion计算机,但可以在其他Linux计算机和 Spock Web控制台

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.

我发现了另一个相关问题:为什么我得到在测试我的控制器时,无法转换对象null错误?

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

我使用的是Grails 2.0.0和Spock 0.6。有什么建议么?似乎是错误

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'


推荐答案

看起来您已点击与Grails 2.0.0的这个错误

这说明它是固定的Grails 2.0.2,

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

手指交叉!

这篇关于使用Spock转换null对象的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆