Robolectric TypedArray的getString()返回null或空字符串 [英] Robolectric TypedArray getString() returns null or empty string

查看:1726
本文介绍了Robolectric TypedArray的getString()返回null或空字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用Robolectric来测试膨胀的自定义视图的活动,但是从TypedArray一切获取值时,回来空或空字符串。需要为了从类型数组得到正确的值做什么?

I'm using Robolectric to test an activity that inflates a custom view, but when fetching values from the TypedArray everything comes back null or an empty string. What needs to be done in order to get the correct value from the typed array?

推荐答案

Robolectric不会重新实现整个Android的标准库。

Robolectric doesn't re-implement the entire Android standard library.

下面是对TypeArray暗影类的链接:
<一href=\"https://github.com/pivotal/robolectric/blob/master/src/main/java/com/xtremelabs/robolectric/shadows/ShadowTypedArray.java\" rel=\"nofollow\">https://github.com/pivotal/robolectric/blob/master/src/main/java/com/xtremelabs/robolectric/shadows/ShadowTypedArray.java

Here is a link to the TypeArray Shadow class: https://github.com/pivotal/robolectric/blob/master/src/main/java/com/xtremelabs/robolectric/shadows/ShadowTypedArray.java

这似乎是缺少一些东西。您可以使用此功能来确认它确实缺少这些功能:
<一href=\"http://pivotal.github.com/robolectric/javadoc/com/xtremelabs/robolectric/Robolectric.html#logMissingInvokedShadowMethods()\" rel=\"nofollow\">http://pivotal.github.com/robolectric/javadoc/com/xtremelabs/robolectric/Robolectric.html#logMissingInvokedShadowMethods()

It seems to be missing some things. You can use this function to confirm that it is indeed missing those functions: http://pivotal.github.com/robolectric/javadoc/com/xtremelabs/robolectric/Robolectric.html#logMissingInvokedShadowMethods()

这是说,有希望。 Robolectric 2.0阿尔法1 最近发布。虽然我还没有使用它,但它声称更少阴影的实现将需要因为它会直接使用Android的实现。

That said, there is hope. Robolectric 2.0 Alpha 1 was recently released. While I haven't used it yet, it claims that less shadow implementations will be needed as it will use the Android implementations directly.

这篇关于Robolectric TypedArray的getString()返回null或空字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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