处理使用Robotium随机对话框 [英] Handle random Dialogs using Robotium

查看:334
本文介绍了处理使用Robotium随机对话框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用Robotium尝试哟测试的登录情况。我困惑的是,我怎么可以测试以下内容:

I am try yo test the login scenario using Robotium. My confusion is that, how could I test following:

案例1:如果Web服务调用过程中出现了一些错误,并随机显示一个对话框,我怎么可以搞定。因为我不知道这是否会出现对话框。

Case 1: If some error occurs during the web service call and a dialog is displayed randomly, how can I handle that. As I'm not sure if this dialog will appear.

案例2:如果这件事情的处理,将试验是失败或传球?因为对于一个成功登录,用户应该导航到下一个屏幕。

Case 2: If this thing is handled, will the test be a fail or a pass? Because for a successful login, user should navigate to next screen.

推荐答案

您知道何时何地会发生此对话框所以它可能在code放置处理对话框。例如:

You know when and where this dialog can happen so its possible to place in code to handle the dialog. for instance:

可以说你有一些code这样的

lets say you have some code like this

solo.clickOnView(view1);

solo.clickOnView(view2);

和你知道的对话框可以测试的这两个步骤中,您可以在code,它是一样的东西的地方:

and you know the dialog can appear between these two steps of your test, you can place in code that is something like:

if(solo.waitForView(dialogView, 1000, false)){
    solo.clickOnView(dialogDismissButton);
    solo.clickOnView(view2) //retry the step above
}

如果其可能的埃罗可能再次发生则可能通过测试失败之前尝试这个周期的时间长度道理把这些电话接入功能和递归/循环。

If its possible the erro can happen again it might make sense to put these calls into function and recursively/loop through trying this cycle for a length of time before failing the test.

至于案件2嗯,这取决于你的成功标准,理想情况下,如果我是你,我会尝试删除导致上述错误,因此不会发生任何外部的依赖关系,但如果你被卡住它是片状。不嘛,用户认为这是一个错误?我可能会说,如果你的生产程序是不能经常登录那么什么是错的应用程序,我会失败的步骤,并没有实现上述几点,但多数民众赞成我的跨pretation,发言的业务分析师/客户/最终用户,并得到他们的观点。

As for case 2. Well this depends on your success criteria, ideally if I was you i would try to remove any external dependancies that cause the above error so it never happens but if you are stuck with it being flaky. Well does a user consider this to be an error? I would probably say that if your production app is failing to login very often then something is wrong with the app and I would fail that step and not implement the points above, but thats my interpretation, speak to the business analyst/customer/end users and get their perspective.

这篇关于处理使用Robotium随机对话框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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