Handle random Dialogs using Robotium

a 夏天 提交于 2019-12-12 01:34:27

问题


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

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.

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.


回答1:


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

lets say you have some code like this

solo.clickOnView(view1);

solo.clickOnView(view2);

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.

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.



来源:https://stackoverflow.com/questions/14375456/handle-random-dialogs-using-robotium

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!