Uninstall application when testing

时光毁灭记忆、已成空白 提交于 2019-12-23 15:21:17

问题


I'm new to testing in Android with Robotium. How can I programatically uninstall and then install the application before running some of the tests?

For example, in order for me to test the login activity, I need to make sure the login credentials are not saved from a prior run of the app. Or is there another way to do this?


回答1:


You could use the following piece of code (on the machine you're debugging from) to uninstall your application:

Runtime rt = Runtime.getRuntime();
Process pr = rt.exec("adb uninstall your.package");
pr.waitFor();



回答2:


-You can also do that by using UIAutomator -Install the application from play store when starting your test and uninstall after finishing the test. -Additionally It will always install new version from play store.



来源:https://stackoverflow.com/questions/8389465/uninstall-application-when-testing

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