Question

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?

Was it helpful?

Solution

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();

OTHER TIPS

-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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top