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, then launches the
38 ability with \c {aa start}, telling the platform which test shared
39 library to load and where to redirect the test's standard output and
40 exit code inside the application sandbox.
41 \li It streams the test's standard output to the host as the test runs.
42 \li It waits for the test to finish, which it detects when the exit-code
43 file becomes readable. A liveness check catches a crashed process, and an
44 optional no-progress watchdog force-stops a test that stops producing
45 \c PASS or \c FAIL results.
46 \li If the test declares blocking system dialogs and the test's output
47 goes quiet, it dumps the screen layout with \c uitest and clicks the
48 expected button.
49 \li It returns the test's exit code as its own exit code.
50 \endlist
51
52 \section1 How to use it
53
54 The basic syntax is:
55
56 \badcode
57 harmonyostestrunner [OPTIONS] <test-binary> [TESTARGS]
58 \endcode
59
60 The \c {<test-binary>} argument is the path to the test shared library, for
61 example \c {libtst_qobject.so}. Its file name selects which test inside the
62 bundle to run. Anything after it, such as test function names or \c {-v2}, the
63 tool forwards to the test.
64
65 \section2 Options
66
67 The following table lists the command-line options of \c
68 harmonyostestrunner. You can set each option through the environment
69 variable in parentheses. The command-line value takes precedence.
70
71 \table
72 \header
73 \li Option
74 \li Description
75 \row
76 \li \c {--bundle-name <name>}
77 \li HarmonyOS bundle name of the installed test HAP
78 (\c QT_HARMONYOS_BUNDLE_NAME). Defaults to
79 \c org.qtproject.autotests.
80 \row
81 \li \c {--ability-name <name>}
82 \li HarmonyOS ability name inside the test HAP
83 (\c QT_HARMONYOS_ABILITY_NAME). Defaults to \c QAbility.
84 \row
85 \li \c {--hdc <path>}
86 \li Path to the \c hdc tool (\c QT_HARMONYOS_HDC). Defaults to the
87 \c hdc found in \c PATH.
88 \row
89 \li \c {--timeout <seconds>}
90 \li Seconds to wait for a test to complete before aborting
91 (\c QT_HARMONYOS_TEST_TIMEOUT). Defaults to 300.
92 \row
93 \li \c {--no-progress-timeout <seconds>}
94 \li Seconds without a \c PASS or \c FAIL result before the tool declares
95 the test hung (\c QT_HARMONYOS_NO_PROGRESS_TIMEOUT). Defaults to 60;
96 0 disables the watchdog.
97 \row
98 \li \c {--device <key>}
99 \li The \c hdc connect key (\c {-t}) for the target device
100 (\c QT_HARMONYOS_DEVICE). Required when you attach multiple
101 devices.
102 \row
103 \li \c {--test-config <path>}
104 \li Path to the generated test bundle deployment settings
105 (\c QT_HARMONYOS_TEST_CONFIG). The build generates this file, and the
106 CMake test wrapper passes it. The tool reads it for the blocking
107 system dialogs it has to answer.
108 \row
109 \li \c {--help}
110 \li Displays the help information.
111 \row
112 \li \c {--version}
113 \li Displays the tool version.
114 \endtable
115
116 \section2 Example usage
117
118 Run the \c tst_qobject test on a specific device, executing only the
119 \c signalsBlocked test case:
120
121 \badcode
122 harmonyostestrunner --device 127.0.0.1:5555 libtst_qobject.so signalsBlocked
123 \endcode
124
125 For more information about the Qt Test framework, see \l{Qt Test Overview}.
126*/