On this page

Installing Squish for Qt for Android testing

The Squish for Qt for Android testing package is suitable for preparing a Qt on Android application for testing. This package does not include an IDE. You also need a Squish for Qt package on your desktop machine for recording, managing and replaying tests. Please see Installing from Binary Packages for details on installing such a package.

Instrumenting the AUT

The AUT must be rebuilt from source for use with Squish for Qt on Android. We recommend using Qt Creator as your IDE.

  1. Get Qt for Android which can be installed from the Qt Maintenance Tool.
  2. Get the compile tools for your device, with Qt Creator, by going to Preferences - SDKs - Android and Set Up SDK.
  3. Verify that a Kit is available which is appropriate for your device and uses your chosen version of Qt for Android. Select it when you open and configure your AUT's project.
  4. Add the Qt built-in hook to your application project.
  5. In Qt Creator choose Clean, to ensure that [qc]make picks up all parts of Squish for Qt to include them in the final application package. Afterwards choose Run or Debug to build, deploy and run the application on the device.
  6. The application should be running on the Android device now. The Application Output in Qt Creator should (among other log output) show several lines starting with the word Squish, including Squish: Listening on port 4567 for incoming connections where 4567 is the port number of the Qt built-in hook.

Establishing a TCP connection to the AUT

  • If the application is running inside the Android Emulator or if testing over a USB connection is required, the TCP port will need to be forwarded to the desktop machine in order to attach to the AUT. We use the adb command, which comes from the Android SDK platform-tools.
    $ adb forward tcp:<portnumber> tcp:<portnumber>

    Replace <portnumber> with the number you chose for the Qt built-in hook.

  • If not done already, install a Squish for Qt binary package on the desktop machine. For remote testing Qt on Android, the Qt version and compiler version of this package do not need to match exactly, but the Qt major version (5 or 6) should be the same for both packages.
  • In Squish IDE choose File, New Test Suite to create a new Test Suite and follow the wizard. When asked for the GUI Toolkit choose Qt. When asked for the Application Under Test choose <No Application>.
  • Follow the steps from Register the Attachable AUT to register the application as an attachable AUT. In case TCP port forwarding via ADB is used, the Host will be localhost.

Verifying that the BuiltIn Hook is running

To verify if the AUT is accepting incoming connections the output of netstat can be used.

$ adb shell netstat -a | grep portnumber
 tcp       0      0 0.0.0.0:portnumber   0.0.0.0:*        LISTEN
C:\users\username> adb shell netstat -a | findstr portnumber
 tcp       0      0 0.0.0.0:portnumber   0.0.0.0:*        LISTEN

Attaching to the running AUT will work if an entry with state LISTEN and the previously passed portnumber is present in the tabular output.

Examples and their Test Suites

In Qt 6.10.0 and later, under Examples/demos, you will find calqlatr and coffee, two QML examples that run on Android, each have a suite of Squish tests already written.

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

Search Results