Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
harmonyostestrunner.qdoc
Go to the documentation of this file.
1// Copyright (C) 2026 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
3
4/*!
5 \page harmonyos-test-runner.html
6 \brief Overview of the harmonyostestrunner tool for running Qt tests on HarmonyOS.
7 \title The harmonyostestrunner Tool
8
9 \target harmonyostestrunner
10
11 \note Qt for HarmonyOS is in technology preview and may change in future
12 releases.
13
14 \section1 Introduction
15
16 The \c harmonyostestrunner tool runs a single Qt auto test on a HarmonyOS
17 device or emulator and reports the result on the host. When you run a test
18 with \c ctest, the CMake test wrapper normally invokes it for you. Invoke it
19 directly when the test HAP is built on one machine but the device is
20 attached to another, or when you have a test HAP but no CMake build tree at
21 hand.
22
23 This tool does not build or install the test package. Instead, \l{The
24 harmonydeployqt Tool}{harmonydeployqt} bundles the test binaries into a
25 single test HAP (through its \c {--test-bundle} option). You must build,
26 sign, and install that HAP on the device beforehand:
27
28 \badcode
29 hdc install <path/to/autotests-signed.hap>
30 \endcode
31
32 \section1 How it works
33
34 \list 1
35 \li It verifies that the target device has the test bundle HAP
36 installed.
37 \li It force-stops any running instance of the bundle and deletes the
38 output files that earlier runs left in the application sandbox. It
39 then launches the ability with \c {aa start}, telling the platform
40 which test shared library to load and where to redirect the test's
41 standard output and exit code inside the application sandbox.
42 \li It streams the test's standard output to the host as the test runs.
43 \li It waits for the test to finish, which it detects when the exit-code
44 file becomes readable. A liveness check catches a crashed process, and an
45 optional no-progress watchdog force-stops a test that stops producing
46 \c PASS or \c FAIL results.
47 \li If the test declares blocking system dialogs and the test's output
48 goes quiet, it dumps the screen layout with \c uitest and clicks the
49 expected button.
50 \li It returns the test's exit code as its own exit code.
51 \endlist
52
53 \section1 How to use it
54
55 The basic syntax is:
56
57 \badcode
58 harmonyostestrunner [OPTIONS] <test-binary> [TESTARGS]
59 \endcode
60
61 The \c {<test-binary>} argument is the path to the test shared library, for
62 example \c {libtst_qobject.so}. Its file name selects which test inside the
63 bundle to run. Anything after it, such as test function names or \c {-v2}, the
64 tool forwards to the test.
65
66 \section2 Options
67
68 The following table lists the command-line options of \c
69 harmonyostestrunner. You can set each option through the environment
70 variable in parentheses. The command-line value takes precedence.
71
72 \table
73 \header
74 \li Option
75 \li Description
76 \row
77 \li \c {--bundle-name <name>}
78 \li HarmonyOS bundle name of the installed test HAP
79 (\c QT_HARMONYOS_BUNDLE_NAME). Defaults to
80 \c org.qtproject.autotests.
81 \row
82 \li \c {--ability-name <name>}
83 \li HarmonyOS ability name inside the test HAP
84 (\c QT_HARMONYOS_ABILITY_NAME). Defaults to \c QAbility.
85 \row
86 \li \c {--hdc <path>}
87 \li Path to the \c hdc tool (\c QT_HARMONYOS_HDC). Defaults to the
88 \c hdc found in \c PATH.
89 \row
90 \li \c {--timeout <seconds>}
91 \li Seconds to wait for a test to complete before aborting
92 (\c QT_HARMONYOS_TEST_TIMEOUT). Defaults to 300.
93 \row
94 \li \c {--no-progress-timeout <seconds>}
95 \li Seconds without a \c PASS or \c FAIL result before the tool declares
96 the test hung (\c QT_HARMONYOS_NO_PROGRESS_TIMEOUT). Defaults to 60;
97 0 disables the watchdog.
98 \row
99 \li \c {--device <key>}
100 \li The \c hdc connect key (\c {-t}) for the target device
101 (\c QT_HARMONYOS_DEVICE). Required when you attach multiple
102 devices.
103 \row
104 \li \c {--test-config <path>}
105 \li Path to the generated test bundle deployment settings
106 (\c QT_HARMONYOS_TEST_CONFIG). The build generates this file, and the
107 CMake test wrapper passes it. The tool reads it for the blocking
108 system dialogs it has to answer.
109 \row
110 \li \c {--help}
111 \li Displays the help information.
112 \row
113 \li \c {--version}
114 \li Displays the tool version.
115 \endtable
116
117 \section2 Example usage
118
119 Run the \c tst_qobject test on a specific device, executing only the
120 \c signalsBlocked test case:
121
122 \badcode
123 harmonyostestrunner --device 127.0.0.1:5555 libtst_qobject.so signalsBlocked
124 \endcode
125
126 For more information about the Qt Test framework, see \l{Qt Test Overview}.
127*/