Reset and install/reinstall don't behave as expected


I’m investigating using Appium for some automated testing on Android. I wrote a few tests that worked well (using py.test, Appium 1.4) but I did so with no resetting of data meaning the tests relied on executing in a certain order. I rewrote these to now be independent but am having problems with how and when Appium resets app data and sessions, in particular, when closing/opening the app.

This is what I want to do:

  • I do want Appium to install the APK when the test run starts.
  • I don’t want Appium to automatically launch the APK.
  • I do want Appium to reset application data between tests, but not completely reinstall the APK.
  • I do want to close/open the application during a test without resetting the data.

To achieve this I’m using the following caps:

desired_caps['autoLaunch'] =  False
desired_caps['noReset'] = False
desired_caps['fullReset'] = False
desired_caps['appPackage'] = ''
desired_caps['appActivity'] = '.App'
desired_caps['noSign'] = True
desired_caps['app'] = 'path/to/apk'

However with this setup the app data is cleared when the app is closed/opened inside of a test (which I need to do) which is not what I want. So I then I thought I’d setting noReset = True and then performing the reset myself using driver.reset(). However that means that the application is not installed when the test run begins and calling reset() appears to attempt to reinstall the application anyway which throws an error checking for a temporary APK on the device (which now isn’t copied to the device because noReset = True).

The way the open/close/reset app methods and the reset caps interact is really confusing and unintuitive. Fixing one problem causes another problem to appear and there doesn’t appear to be an answer that fixes both at the same time. I could shell out to adb to reset data myself, but at some point we want to run these tests on a service and won’t be able to do that there. Is there something I misunderstand or am missing?

Thanks for reading!

Here is a rough overview of the tests I am attempting to implement if helpful:

Test 1:

  • Start timer.
  • Launch app.
  • Complete first run page (clicking buttons).
  • Finish timing.

App data reset

Test 2:

  • Launch app.
  • Complete first run page (clicking buttons).
  • Set in-application setting.
  • Load resource from internet. Wait for complete.
  • Close app (not suspend it).
  • Start timer.
  • Reopen app.
  • Wait for state and resource to reload.
  • End timer.