Testing Application Upgrades

Capture

       Tester’s responsibility goes beyond the functionality of an app in just one version. We also care about issues that might arise as users migrate from one version to another. Your customers are upgrading to the latest version, not installing it from scratch. There might be all kinds of existing user data that needs to be migrated for the app to work correctly, and simply running functional tests of the new version would not be sufficient to catch these cases. In this article, I would like to share the testing of application upgrades for both iOS and Android. Appium supports the application upgrade testing.

Testing Android Application Upgrades

    Appium comes with some built-in commands to handle this kind of requirement. Fortunately, on Android, it’s even simpler than on iOS. Basically, we take advantage of the following two methods:

driver.installApp(“/path/to/apk”);

// ‘activity’ is an instance of import io.appium.java_client.android.Activity;
driver.startActivity(activity);

This set of commands:

  • Replaces the existing app with the one given in the path (or URL) as the argument to installApp, and in so doing stops the old version of the app from running (so there is no need to explicitly stop the app before installing the new one).
  • Starts up the new version of the app using its package name and whatever activity you choose.

       Here is that the argument to startActivity must be of type Activity. There is a separate Activity class because there are a number of options that can be passed to this method. We’re only interested in the basic ones for the purposes of app upgrades, so we can simply create our Activity object as follows:

Activity activity = new Activity(“com.mycompany.myapp”, “MyActivity”);
driver.startActivity(activity);

      In the real scenario of automation, the old version of the application can launch by specifying the old application path along with the desired capability. After that upgrade and launch application version with the help of installApp and startActivity methods

Testing iOS Application Upgrades

     In Android, we did the application upgrade with the help of two methods in an easy way. In the case of iOS, we take advantage of these three mobile: methods:

driver.executeScript(“mobile: terminateApp“, args);
driver.executeScript(“mobile: installApp“, args);
driver.executeScript(“mobile: launchApp“, args);

      This set of commands stops the current app (which we need to do explicitly so that the underlying WebDriverAgent instance doesn’t think the app has crashed on us), installs the new app over the top of it, and then launches the new app.

        The terminateApp and launchApp commands both have one key, bundleId (which is the bundle ID of your app). installApp takes an app key, which is the path or URL to the new version of your app. Below is the sample snippet:

HashMap<String, String> bundleArgs = new HashMap<>();
bundleArgs.put(“bundleId”, BUNDLE_ID_OF_OLD_APP);
driver.executeScript(“mobile: terminateApp“, bundleArgs);

HashMap<String, String> installArgs = new HashMap<>();
installArgs.put(“app”, APP_URL_OF_THE_NEW_APP);
driver.executeScript(“mobile: installApp“, installArgs);

// can just reuse args for terminateApp
driver.executeScript(“mobile: launchApp“, bundleArgs);

       Try to use the above logic in your automation testing using Appium, especially the area where the application upgrade test required.

Reference: Appium Pro

make it perfect!