On this page

The harmonyostestrunner Tool

Note: Qt for HarmonyOS is in technology preview and may change in future releases.

Introduction

The harmonyostestrunner tool runs a single Qt auto test on a HarmonyOS device or emulator and reports the result on the host. When you run a test with ctest, the CMake test wrapper normally invokes it for you. Invoke it directly when the test HAP is built on one machine but the device is attached to another, or when you have a test HAP but no CMake build tree at hand.

This tool does not build or install the test package. Instead, harmonydeployqt bundles the test binaries into a single test HAP (through its --test-bundle option). You must build, sign, and install that HAP on the device beforehand:

hdc install <path/to/autotests-signed.hap>

How it works

  1. It verifies that the target device has the test bundle HAP installed.
  2. It force-stops any running instance of the bundle, then launches the ability with aa start, telling the platform which test shared library to load and where to redirect the test's standard output and exit code inside the application sandbox.
  3. It streams the test's standard output to the host as the test runs.
  4. It waits for the test to finish, which it detects when the exit-code file becomes readable. A liveness check catches a crashed process, and an optional no-progress watchdog force-stops a test that stops producing PASS or FAIL results.
  5. If the test declares blocking system dialogs and the test's output goes quiet, it dumps the screen layout with uitest and clicks the expected button.
  6. It returns the test's exit code as its own exit code.

How to use it

The basic syntax is:

harmonyostestrunner [OPTIONS] <test-binary> [TESTARGS]

The <test-binary> argument is the path to the test shared library, for example libtst_qobject.so. Its file name selects which test inside the bundle to run. Anything after it, such as test function names or -v2, the tool forwards to the test.

Options

The following table lists the command-line options of harmonyostestrunner. You can set each option through the environment variable in parentheses. The command-line value takes precedence.

OptionDescription
--bundle-name <name>HarmonyOS bundle name of the installed test HAP (QT_HARMONYOS_BUNDLE_NAME). Defaults to org.qtproject.autotests.
--ability-name <name>HarmonyOS ability name inside the test HAP (QT_HARMONYOS_ABILITY_NAME). Defaults to QAbility.
--hdc <path>Path to the hdc tool (QT_HARMONYOS_HDC). Defaults to the hdc found in PATH.
--timeout <seconds>Seconds to wait for a test to complete before aborting (QT_HARMONYOS_TEST_TIMEOUT). Defaults to 300.
--no-progress-timeout <seconds>Seconds without a PASS or FAIL result before the tool declares the test hung (QT_HARMONYOS_NO_PROGRESS_TIMEOUT). Defaults to 60; 0 disables the watchdog.
--device <key>The hdc connect key (-t) for the target device (QT_HARMONYOS_DEVICE). Required when you attach multiple devices.
--test-config <path>Path to the generated test bundle deployment settings (QT_HARMONYOS_TEST_CONFIG). The build generates this file, and the CMake test wrapper passes it. The tool reads it for the blocking system dialogs it has to answer.
--helpDisplays the help information.
--versionDisplays the tool version.

Example usage

Run the tst_qobject test on a specific device, executing only the signalsBlocked test case:

harmonyostestrunner --device 127.0.0.1:5555 libtst_qobject.so signalsBlocked

For more information about the Qt Test framework, see Qt Test Overview.

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