Android的&放大器; Robotium - 测试的活动,期待一个额外的? [英] Android & Robotium - Test activity that expects an extra?
问题描述
在我看来,这robotium设计的方式来测试1活动的时间,而不是整个应用程序。
It seems to me that robotium was designed in a way to test 1 Activity at a time instead of the whole application.
所以我的问题是我怎么测试预计额外的传递给它的活动?
通过额外的我的意思是 intent.putExtra(东西,对象);
So my question is how do I test an activity that expects an extra to be passed to it?
by extra I mean intent.putExtra("Something", object);
推荐答案
该方法的 setActivityIntent(意向)应该是你所期待的。我用这个方法来提供自定义的意图我活动的TestCase。只要使用它,您拨打的超在构造函数后。
The method setActivityIntent(Intent) should be what you are looking for. I used this method to provide a custom Intent to my Activity's TestCase. Just use it after you call super in your constructor.
Intent i = new Intent();
i.putExtra("myExtra", "anyValue");
setActivityIntent(i);
您不必做,在构造函数中,我认为,但你需要确保你把它叫做在打电话之前getActivity()首次。 getActivity会使用你的意图创建活动。
You don't have to do it in the constructor i think, but you need to make sure that you call it before you call getActivity() for the first time. getActivity will use your Intent to create the Activity.
这篇关于Android的&放大器; Robotium - 测试的活动,期待一个额外的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!