The Mobile Developer’s Guides

If you are interested in developing, testing, and marketing mobile apps there are several excellent eBooks available that include these topics. I liked the books so much I’ve ended up contributing to both of them. They are collaborative works with multiple contributors and authors. They are fun, easy to read and slightly quirky.

Here are links to both of them:
http://www.wipconnector.com/download/GuideToTheParallelUniverse_3rdEdition.pdf (this is the guide on how to market your mobile app). My contribution is the introduction to Mobile Analytics topic.

http://www.enough.de/products/mobile-developers-guide/ has a download link to the current version of the Development Guide – advises people on how to develop (write/create) and test mobile apps.I’ve written several chapters entirely, including the ones on testing and mobile analytics, and edit the entire book.

Human Testing for Mobile Apps

Automated software tests are topical where they seem to be replacing much of the testing done by humans. Automated tests are faster, provide early feedback and cost little to run many times. Agile projects need automated tests to keep up with the frequent builds which may arrive tens or hundreds of times a day and need testing.

So human testing seems to be gathering cobwebs, even despised as unproductive, low-skilled work done by testers who don’t have the ‘skills’ to write automated tests. However, as an industry we ignore testing by humans at our peril. There’s so much testing that’s beyond practical reach of automated tests. It’s time to revive interactive testing performed by motivated and interested humans. This talk will help you to find a new impetus and focus for your interactive testing to complement automated tests.

Feelings and emotions are what users will judge your apps on, so let’s test and explore how users may feel about the mobile apps. Michael Bolton published an insightful article called: “I’ve Got a Feeling: Emotions in Testing by Michael Bolton”

Fast, efficient testing can augment the repetitive automated testing. BugFests, where a group of people meet to test the same piece of software together for up to an hour can be extremely productive at finding problems the automated tests haven’t.

Another technique is moving both you (from place to place) and the phone (by rotating it from portrait to landscape modes, etc.) may help find and expose bugs which are hard for your automated tests to discover.

I will be giving a keynote at VistaCon 2013 in April 2013 on this topic. Please email me if you would like to get involved in the discussion, share ideas, criticize, etc.

Android Test Automation Getting to grips with UI Automator

Over the last week I have spent about a day of effort getting to grips with the recently launched UIAutomator test automation framework for Android. It was launched with version 16 of Android (Android 4.1) however on 4.1 devices the framework doesn’t even have all the documented methods available. With version 17 of Android (Android 4.2), support has improved to the point that the examples can work acceptably. Here is the official example http://developer.android.com/tools/testing/testing_ui.html

However in the minor update between Android 4.2.1 and Android 4.2.2 someone seems to have broken the support for automatic scrolling through pages of results.  I have reported the problem on the adt-dev forum, https://groups.google.com/forum/?fromgroups=#!topic/adt-dev/TjeewtpNWf8 which seems to be where the Android development team monitor comments. I have implemented a workaround, using a helper method, below:

    /**
     * Launches an app by it's name. 
     * 
     * @param nameOfAppToLaunch the localized name, an exact match is required to launch it.
     */
    protected static void launchAppCalled(String nameOfAppToLaunch) throws UiObjectNotFoundException {
        UiScrollable appViews = new UiScrollable(new UiSelector().scrollable(true));
          // Set the swiping mode to horizontal (the default is vertical)
          appViews.setAsHorizontalList();
          appViews.scrollToBeginning(10);  // Otherwise the Apps may be on a later page of apps.
          int maxSearchSwipes = appViews.getMaxSearchSwipes();

          UiSelector selector;
          selector = new UiSelector().className(android.widget.TextView.class.getName());
          
          UiObject appToLaunch;
          
          // The following loop is to workaround a bug in Android 4.2.2 which
          // fails to scroll more than once into view.
          for (int i = 0; i < maxSearchSwipes; i++) {

              try {
                  appToLaunch = appViews.getChildByText(selector, nameOfAppToLaunch);
                  if (appToLaunch != null) {
                      // Create a UiSelector to find the Settings app and simulate      
                      // a user click to launch the app.
                      appToLaunch.clickAndWaitForNewWindow();
                      break;
                  }
              } catch (UiObjectNotFoundException e) {
                  System.out.println("Did not find match for " + e.getLocalizedMessage());
              }

              for (int j = 0; j < i; j++) {
                  appViews.scrollForward();
                  System.out.println("scrolling forward 1 page of apps.");
              }
          }
    }

I ended up writing several skeletal demo Android apps to help me explore the capabilities of UI Automator. In each case I was working through publicly reported problems on http://stackoverflow.com where I’ve posted answers and feedback to several reported problems.

Here are the links to my comments:

http://stackoverflow.com/questions/13991977/how-to-switch-on-wifi-in-uiautomator-test-case-in-android-device

http://stackoverflow.com/questions/15204154/uiautomator-failing-on-4-1-2-device

http://stackoverflow.com/questions/15111001/uiautomator-getlasttraversedtext

Strengths of UI Automator

The key strengths include:

  • We can test most applications, including Google’s installed apps such as Settings. Thankfully the example from the Android site does just that, albeit at a perfunctory level. However the example to change the Wi-Fi setting on stackoverflow provides a better example of what we can now do. Because the tests interact with the objects, they have a direct connection to the app being tested, rather than crude interactions by clicking at locations, OCR, etc.
  • Using UI Automator relies on the underlying support for Accessibility in the platform and therefore may help to encourage improved support for Accessible Android apps as developers refine their apps to make them testable by Ui Automator.
  • We can test apps on several devices from one computer, through related changes to the Android build tools.
  • There are debug and exploration tools available on both the device (using adb shell uiautomator) and from my computer, using uiautomationviewer.

Weaknesses

  • Text based matching makes testing localized apps much harder than using the older Android Instrumentation which could easily share resource files with the app being tested.
  • There is virtually no documentation or examples, and the documentation that does exist doesn’t provide enough clues to address key challenges e.g. obtaining the text from WebViews.
  • UI Automation cannot be used when the Accessibility features e.g. Explore-By-Touch is enabled on the device.
  • There are bugs in the current version of Android and there’s no easy way to revert devices to 4.2.1
  • Automation is very slow e.g. paging through the set of apps takes several seconds to go to the next page.

Other characteristics

  • All the tests are bundled into a single jar file, deployed to the device. This risks one set of tests overwriting the bundle of tests.

Further reading