4

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?

Catalin Morosan
  • 7,897
  • 11
  • 53
  • 73

2 Answers2

6

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();
Sveinung Kval Bakken
  • 3,715
  • 1
  • 24
  • 30
0

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

Manish Saini
  • 113
  • 3
  • 11
  • Your suggestion doesn't work though for real testing, as you normally test app versions that are NOT yet distributed in the app store, because you changed something locally and want to run tests on the new version to make sure you can actually distribute it. – Sarah Multitasker May 03 '23 at 11:16