使用Spock来调用空对象的问题 [英] Problems casting a null object with Spock

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

问题描述

我有一个Spock测试失败了两台Mac OS X Lion机器,但适用于其他Linux机器和 Spock Web Console



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



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

  defcast null object(){
expect:
null as BigDecimal == null
}

|失败:转换null对象(com.arturoherrero.MySpec)
| org.codehaus.groovy.runtime.typehandling.GroovyCastException:不能将类'org.codehaus.groovy.runtime.NullObject'转换为'java.math.BigDecimal'类'


解决方案

看起来你打了这个错误与Grails 2.0.0



这说明它是固定的Grails 2.0.2,所以可能是您的一台机器上的升级是为了检查?



手指横过!


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'

解决方案

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!

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

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