简体   繁体   English

如何使用Robotium Test提取片段的变量值?

[英]How can I use Robotium Test to extract variable value of a Fragment?

I have a Fragment which sets a certain value inside a Fragment. 我有一个片段,它在片段内设置了某个值。 It does not put it in a UI element but its a stored value. 它不会将其放在UI元素中,而是其存储的值。 How can I extract his value using Robotium solo object? 如何使用Robotium单独对象提取他的值? The examples I see are all about testing UI elements, but what if the value is a variable of the Fragment? 我看到的示例都是关于测试UI元素的,但是如果值是Fragment的变量怎么办?

I think i cover most of this here: How do I get a reference to a fragment from within a unit/robotium test? 我想我在这里涵盖了大部分内容: 如何从单元/实验室测试中引用片段?

but there is one thing that does not cover, and that is that you will have to unsafely cast the fragment you receive into the fragment class that you have a method to call in order to get the value or alternatively use reflection on the fragment returned to peek into the internal state (I vote you go for option one) 但是有一件事情没有涵盖,那就是您将不得不不安全地将收到的片段转换为您可以调用该方法的片段类,以获取该值,或者对返回的片段使用反射。窥探内部状态(我投票赞成选择一种方法)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM