Installing Squish for Android
Squish can be used to test software for Android that meets the following prerequisites:
- The application must provide a user interface.
- From the application, a test package has to be made and installed.
For the second prerequisite, a Java JDK, version 7 or higher, and optionally the Android SDK have to be installed.
With the prerequisites in place, Squish can be used to test the application, either using an Android emulator or using an Android device connected to the machine running Squish via USB.
For finding some UI elements, Squish has to use Java reflection. These code paths may break in future, yet unsupported, Android versions. Therefore, since Android-28 (Android Pie), a warning dialog informs the user about this access. Of course, that breaks UI testing, and therefore Squish disables warning dialogs, but keeps warnings in the log (the
Note: On Windows, when testing on a real device using USB, a special USB driver for development and debugging from the vendor of the specific Android device or model must be installed. See OEM USB Drivers. The fact that an Android device shows up as a usable device in the operating system is usually not sufficient.
Note: On Linux, when testing on a real device using USB, make sure the access permissions to the device are configured properly. See Using Hardware Devices.
Make the Android app testable
Squish can record and replay test scripts for your application when there is a package containing the SquishHook instrumentation that has the target set to your application's package name.
Using a separate test package
This is the method used by the Squish IDE. It will build a test apk, re-sign your apk and finally install both. Either when choosing a new package in the test suite settings page or Manage Android AUTs in the Server Settings.
For command-line users, to create a test package, re-sign yours and install, run:
apk-tool -a <path-to-android-sdk> -j <jdk> -pkg <your-apk> -o <temp-dir> -d <device>
apk-tool is a script found in the Squish
jdk the full path to a Java JDK, version 7 or higher, and
temp-dir some directory where
apk-tool writes some temporary files.
-a option may be omitted because Squish includes the required tools. Use it when your app uses more up-to-date resources from the Android SDK.
-j option may be omitted when both
jarsigner are in your path.
You can pass multiple
-d device pairs to the apk-tool.
Note: The packages installed by
apk-tool may conflict with a previously installed package due to re-signing. Either uninstall it manually first or edit the
Settings for Signing field to match the keystore and credential your apk is using.
Using a built-in SquishHook
This is an alternative method to get a testable application. Instead of creating a test apk, the squish hook can be built-in, too. This may be a faster compile/test cycle in some work loads.
We take as example
AddressBook, which you can find in the
android directory under
This project was created as:
$ android-sdk/tools/android create project --target android-8 \ --name AddressBook --path AddressBook \ --activity AddressBook --package com.froglogic.addressbook
To compile this application yourself, first create a
local.properties file containing:
Note: On Windows, either use forward slashes or use double backslashes for the path.
Next, create a
project.properties file containing:
Look in your Android SDK directory for the possible targets that are the subdirectories under
android-sdk/targets/. Here we use target
Then create a
libs subdirectory and copy the file
squishandroid.jar in there.
To add support for UiAutomation, also the jars testing-support-lib and uiautomator can be copied to
libs. These two jars can be retrieved from the Android-SDK
extras/android/m2repository/com/android/support/test directory, when having 'Android Support Repository' installed. Unzip the
aar files and rename
classes.jar so that these two jars don't overwrite each other.
AndroidManifest.xml file to enable Squish instrumentation and to add the
Note: The above two steps have been done for the AddressBook application already.
To build the application, execute:
$ ant debug
Start the device or emulator, and once it is ready, install the application by executing:
$ android-sdk/platform-tools/adb install -r bin/AddressBook-debug.apk
Where android-sdk is the full path to your Android SDK installation.
Starting the AUT
For more information about starting the application in a test script, see Notes on using startApplication with Android.
To check that Squish can see multiple devices and emulators, execute:
squishrunner --info androidDevices
To see all applications that Squish can use, run:
squishrunner --info androidInstrumentation
Note: squishserver must be running to handle the
© 2023 The Qt Company Ltd.
Documentation contributions included herein are the copyrights of
their respective owners.
The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation.
Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.