与robotium测试活动流程 [英] Testing activity flow with robotium

查看:133
本文介绍了与robotium测试活动流程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想用robotium测试一些流程

I want to test some flow using robotium

我的流程要经过几次活动,并在中间做一些断言

my flow has to go through several activities, and do some assertions in the middle

我的问题是,一旦活动的变化,测试成功结束

my problem is, that once the activity changes, the test ends successfully

如何测试通过几次活动1试验走向何方?

how do i test going through several activities in 1 test?

我使用robotium 5.0.1

i am using robotium 5.0.1

推荐答案

它很简单的实现。您可以触发事件,并声称使用一种方法里面API检查结果

Its quite simple to achieve. You can fire event and check result using assert API inside one method

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");
}

这就是它,你在一气呵成完成的。

Thats it and you are done in one go.

这篇关于与robotium测试活动流程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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