我想使用robotium测试一些流程
我的流程必须经历几个活动,并在中间做一些断言
我的问题是,一旦活动发生变化,测试就会成功结束
我如何测试1次测试中的几项活动?
我正在使用robotium 5.0.1
答案 0 :(得分:1)
实现起来非常简单。您可以使用一个方法中的assert API来触发事件并检查结果
public void testAllActivity(){
Solo solo = new Solo(getInstrumentation(), getActivity());
// View1 is a view that is lying in Activity1
solo.clickOnButton(view1);
// Put a delay so that you testing with assert doesn't fail.
solo.waitForActivity("Activity2");
solo.assertCurrentActivity("<Error Message>","Activity2.class");
// View2 is a view that is lying in Activity2
solo.clickOnButton(view1);
// Put a delay so that you testing with assert doesn't fail.
solo.waitForActivity("Activity3");
solo.assertCurrentActivity("<Error Message>","Activity3.class");
}
多数民众赞成,你一次完成。
答案 1 :(得分:0)
Robotium应该能够很好地处理切换活动。
您是否正在使用Solo点击按钮(或图像等...),即
Solo solo = new Solo(getInstrumentation(), getActivity());
//button is a button in activity1 that launches activity2
solo.clickOnButton(button);
//Now we are in Activity2
//otherButton is a button in activity2 that launches activity3
solo.clickOnButton(otherButton);
//Now we are in Activity3
//Check the Current Activity
solo.assertCurrentActivity("Error Message", Activity3.class);
发布一些代码可能会让您获得更个性化的回复
这也可能有所帮助: https://groups.google.com/forum/#!topic/robotium-developers/lcneCX_nYPQ