1e41f4b71Sopenharmony_ci# arkXtest User Guide
2e41f4b71Sopenharmony_ci
3e41f4b71Sopenharmony_ci
4e41f4b71Sopenharmony_ci## Overview
5e41f4b71Sopenharmony_ci
6e41f4b71Sopenharmony_ciarkXtest is an automated test framework that consists of JsUnit and UiTest.<br>JsUnit is a unit test framework that provides basic APIs for compiling test cases and generating test reports for testing system and application APIs.<br>UiTest is a UI test framework that provides the UI component search and operation capabilities through simple and easy-to-use APIs, and allows you to develop automated test scripts based on GUI operations. This document will help to familiarize you with arkXtest, describing its main functions, implementation principles, environment setup, and test script compilation and execution.
7e41f4b71Sopenharmony_ci
8e41f4b71Sopenharmony_ci
9e41f4b71Sopenharmony_ci## Implementation
10e41f4b71Sopenharmony_ci
11e41f4b71Sopenharmony_ciarkXtest is divided into two parts: unit test framework and UI test framework.<br>As the backbone of arkXtest, the unit test framework offers such features as identifying, scheduling, and executing test scripts, as well as summarizing test script execution results.<br>The UI test framework provides UiTest APIs for you to call in different test scenarios. Its test scripts are executed on top of the unit test framework.
12e41f4b71Sopenharmony_ci
13e41f4b71Sopenharmony_ci### Unit Test Framework
14e41f4b71Sopenharmony_ci
15e41f4b71Sopenharmony_ci  Figure 1 Main functions of the unit test framework
16e41f4b71Sopenharmony_ci
17e41f4b71Sopenharmony_ci  ![](figures/UnitTest.PNG)
18e41f4b71Sopenharmony_ci
19e41f4b71Sopenharmony_ci  Figure 2 Basic script process
20e41f4b71Sopenharmony_ci
21e41f4b71Sopenharmony_ci  ![](figures/TestFlow.PNG)
22e41f4b71Sopenharmony_ci
23e41f4b71Sopenharmony_ci
24e41f4b71Sopenharmony_ci### UI Test Framework
25e41f4b71Sopenharmony_ci
26e41f4b71Sopenharmony_ci  Figure 3 Main functions of the UI test framework
27e41f4b71Sopenharmony_ci
28e41f4b71Sopenharmony_ci  ![](figures/Uitest.PNG)
29e41f4b71Sopenharmony_ci
30e41f4b71Sopenharmony_ci
31e41f4b71Sopenharmony_ci## Constraints
32e41f4b71Sopenharmony_ci
33e41f4b71Sopenharmony_ci- The features of the UI test framework are available only in OpenHarmony 3.1 Release and later versions.
34e41f4b71Sopenharmony_ci
35e41f4b71Sopenharmony_ci## Preparing the Environment
36e41f4b71Sopenharmony_ci
37e41f4b71Sopenharmony_ci### Environment Requirements
38e41f4b71Sopenharmony_ci
39e41f4b71Sopenharmony_ci- Software: DevEco Studio 3.0 or later
40e41f4b71Sopenharmony_ci
41e41f4b71Sopenharmony_ci- Hardware: PC connected to a test device, such as a <!--RP1-->development board<!--RP1End-->.
42e41f4b71Sopenharmony_ci
43e41f4b71Sopenharmony_ci### Setting Up the Environment
44e41f4b71Sopenharmony_ci
45e41f4b71Sopenharmony_ci[Download DevEco Studio](https://developer.harmonyos.com/cn/develop/deveco-studio#download) and set it up as instructed on the official website.
46e41f4b71Sopenharmony_ci
47e41f4b71Sopenharmony_ci## Creating and Compiling a Test Script
48e41f4b71Sopenharmony_ci
49e41f4b71Sopenharmony_ci### Creating a Test Script
50e41f4b71Sopenharmony_ci
51e41f4b71Sopenharmony_ci<!--RP2-->
52e41f4b71Sopenharmony_ci1. Open DevEco Studio and create a project, in which the **ohos** directory is where the test script is located.
53e41f4b71Sopenharmony_ci2. Open the **.ets** file of the module to be tested in the project directory. Move the cursor to any position in the code, and then right-click and choose **Show Context Actions** > **Create Ohos Test** or press **Alt+Enter** and choose **Create Ohos Test** to create a test class. For more details, see [DevEco Studio User Guide](https://developer.harmonyos.com/en/docs/documentation/doc-guides-V3/harmonyos_jnit_jsunit-0000001092459608-V3?catalogVersion=V3#section13366184061415).
54e41f4b71Sopenharmony_ci<!--RP2End-->
55e41f4b71Sopenharmony_ci
56e41f4b71Sopenharmony_ci### Writing a Unit Test Script
57e41f4b71Sopenharmony_ci
58e41f4b71Sopenharmony_ciThis section describes how to use the unit test framework to write a unit test script. For details about the functionality of the unit test framework, see [arkXtest](https://gitee.com/openharmony/testfwk_arkxtest/blob/master/README_en.md).
59e41f4b71Sopenharmony_ci
60e41f4b71Sopenharmony_ciThe unit test script must contain the following basic elements:
61e41f4b71Sopenharmony_ci
62e41f4b71Sopenharmony_ci1. Import of the dependencies so that the dependent test APIs can be used.
63e41f4b71Sopenharmony_ci
64e41f4b71Sopenharmony_ci2. Test code, mainly about the related logic, such as API invoking.
65e41f4b71Sopenharmony_ci
66e41f4b71Sopenharmony_ci3. Invoking of the assertion APIs and setting of checkpoints. If there is no checkpoint, the test script is considered as incomplete.
67e41f4b71Sopenharmony_ci
68e41f4b71Sopenharmony_ciThe following sample code is used to start the test page to check whether the page displayed on the device is the expected page.
69e41f4b71Sopenharmony_ci
70e41f4b71Sopenharmony_ci```ts
71e41f4b71Sopenharmony_ciimport { describe, it, expect } from '@ohos/hypium';
72e41f4b71Sopenharmony_ciimport { abilityDelegatorRegistry } from '@kit.TestKit';
73e41f4b71Sopenharmony_ciimport { UIAbility, Want } from '@kit.AbilityKit';
74e41f4b71Sopenharmony_ci
75e41f4b71Sopenharmony_ciconst delegator = abilityDelegatorRegistry.getAbilityDelegator()
76e41f4b71Sopenharmony_ciconst bundleName = abilityDelegatorRegistry.getArguments().bundleName;
77e41f4b71Sopenharmony_cifunction sleep(time: number) {
78e41f4b71Sopenharmony_ci  return new Promise<void>((resolve: Function) => setTimeout(resolve, time));
79e41f4b71Sopenharmony_ci}
80e41f4b71Sopenharmony_ciexport default function abilityTest() {
81e41f4b71Sopenharmony_ci  describe('ActsAbilityTest', () =>{
82e41f4b71Sopenharmony_ci    it('testUiExample',0, async (done: Function) => {
83e41f4b71Sopenharmony_ci      console.info("uitest: TestUiExample begin");
84e41f4b71Sopenharmony_ci      //start tested ability
85e41f4b71Sopenharmony_ci      const want: Want = {
86e41f4b71Sopenharmony_ci        bundleName: bundleName,
87e41f4b71Sopenharmony_ci        abilityName: 'EntryAbility'
88e41f4b71Sopenharmony_ci      }
89e41f4b71Sopenharmony_ci      await delegator.startAbility(want);
90e41f4b71Sopenharmony_ci      await sleep(1000);
91e41f4b71Sopenharmony_ci      // Check the top display ability.
92e41f4b71Sopenharmony_ci      await delegator.getCurrentTopAbility().then((Ability: UIAbility)=>{
93e41f4b71Sopenharmony_ci        console.info("get top ability");
94e41f4b71Sopenharmony_ci        expect(Ability.context.abilityInfo.name).assertEqual('EntryAbility');
95e41f4b71Sopenharmony_ci      })
96e41f4b71Sopenharmony_ci      done();
97e41f4b71Sopenharmony_ci    })
98e41f4b71Sopenharmony_ci  })
99e41f4b71Sopenharmony_ci}
100e41f4b71Sopenharmony_ci```
101e41f4b71Sopenharmony_ci
102e41f4b71Sopenharmony_ci### Writing a UI Test Script
103e41f4b71Sopenharmony_ci
104e41f4b71Sopenharmony_ci <br>To write a UI test script to complete the corresponding test activities, simply add the invoking of the UiTest API to a unit test script. For details about the available APIs, see [@ohos.UiTest](../../application-dev/reference/apis-test-kit/js-apis-uitest.md).<br>In this example, the UI test script is written based on the preceding unit test script. It implements the click operation on the started application page and checks whether the page changes as expected.
105e41f4b71Sopenharmony_ci
106e41f4b71Sopenharmony_ci1. Write the demo code in the **index.ets** file.
107e41f4b71Sopenharmony_ci
108e41f4b71Sopenharmony_ci```ts
109e41f4b71Sopenharmony_ci@Entry
110e41f4b71Sopenharmony_ci@Component
111e41f4b71Sopenharmony_cistruct Index {
112e41f4b71Sopenharmony_ci  @State message: string = 'Hello World'
113e41f4b71Sopenharmony_ci
114e41f4b71Sopenharmony_ci  build() {
115e41f4b71Sopenharmony_ci    Row() {
116e41f4b71Sopenharmony_ci      Column() {
117e41f4b71Sopenharmony_ci        Text(this.message)
118e41f4b71Sopenharmony_ci          .fontSize(50)
119e41f4b71Sopenharmony_ci          .fontWeight(FontWeight.Bold)
120e41f4b71Sopenharmony_ci        Text("Next")
121e41f4b71Sopenharmony_ci          .fontSize(50)
122e41f4b71Sopenharmony_ci          .margin({top:20})
123e41f4b71Sopenharmony_ci          .fontWeight(FontWeight.Bold)
124e41f4b71Sopenharmony_ci        Text("after click")
125e41f4b71Sopenharmony_ci          .fontSize(50)
126e41f4b71Sopenharmony_ci          .margin({top:20})
127e41f4b71Sopenharmony_ci          .fontWeight(FontWeight.Bold)
128e41f4b71Sopenharmony_ci      }
129e41f4b71Sopenharmony_ci      .width('100%')
130e41f4b71Sopenharmony_ci    }
131e41f4b71Sopenharmony_ci    .height('100%')
132e41f4b71Sopenharmony_ci  }
133e41f4b71Sopenharmony_ci}
134e41f4b71Sopenharmony_ci```
135e41f4b71Sopenharmony_ci
136e41f4b71Sopenharmony_ci2. Write test code in the **.test.ets** file under **ohosTest** > **ets** > **test**.
137e41f4b71Sopenharmony_ci
138e41f4b71Sopenharmony_ci```ts
139e41f4b71Sopenharmony_ciimport { describe, it, expect } from '@ohos/hypium';
140e41f4b71Sopenharmony_ci// Import the test dependencies.
141e41f4b71Sopenharmony_ciimport { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit';
142e41f4b71Sopenharmony_ciimport { UIAbility, Want } from '@kit.AbilityKit';
143e41f4b71Sopenharmony_ci
144e41f4b71Sopenharmony_ciconst delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator()
145e41f4b71Sopenharmony_ciconst bundleName = abilityDelegatorRegistry.getArguments().bundleName;
146e41f4b71Sopenharmony_cifunction sleep(time: number) {
147e41f4b71Sopenharmony_ci  return new Promise<void>((resolve: Function) => setTimeout(resolve, time));
148e41f4b71Sopenharmony_ci}
149e41f4b71Sopenharmony_ciexport default function abilityTest() {
150e41f4b71Sopenharmony_ci  describe('ActsAbilityTest', () => {
151e41f4b71Sopenharmony_ci    it('testUiExample',0, async (done: Function) => {
152e41f4b71Sopenharmony_ci      console.info("uitest: TestUiExample begin");
153e41f4b71Sopenharmony_ci      //start tested ability
154e41f4b71Sopenharmony_ci      const want: Want = {
155e41f4b71Sopenharmony_ci        bundleName: bundleName,
156e41f4b71Sopenharmony_ci        abilityName: 'EntryAbility'
157e41f4b71Sopenharmony_ci      }
158e41f4b71Sopenharmony_ci      await delegator.startAbility(want);
159e41f4b71Sopenharmony_ci      await sleep(1000);
160e41f4b71Sopenharmony_ci      // Check the top display ability.
161e41f4b71Sopenharmony_ci      await delegator.getCurrentTopAbility().then((Ability: UIAbility)=>{
162e41f4b71Sopenharmony_ci        console.info("get top ability");
163e41f4b71Sopenharmony_ci        expect(Ability.context.abilityInfo.name).assertEqual('EntryAbility');
164e41f4b71Sopenharmony_ci      })
165e41f4b71Sopenharmony_ci      // UI test code
166e41f4b71Sopenharmony_ci      // Initialize the driver.
167e41f4b71Sopenharmony_ci      let driver = Driver.create();
168e41f4b71Sopenharmony_ci      await driver.delayMs(1000);
169e41f4b71Sopenharmony_ci      // Find the button on text 'Next'.
170e41f4b71Sopenharmony_ci      let button = await driver.findComponent(ON.text('Next'));
171e41f4b71Sopenharmony_ci      // Click the button.
172e41f4b71Sopenharmony_ci      await button.click();
173e41f4b71Sopenharmony_ci      await driver.delayMs(1000);
174e41f4b71Sopenharmony_ci      // Check text.
175e41f4b71Sopenharmony_ci      await driver.assertComponentExist(ON.text('after click'));
176e41f4b71Sopenharmony_ci      await driver.pressBack();
177e41f4b71Sopenharmony_ci      done();
178e41f4b71Sopenharmony_ci    })
179e41f4b71Sopenharmony_ci  })
180e41f4b71Sopenharmony_ci}
181e41f4b71Sopenharmony_ci```
182e41f4b71Sopenharmony_ci
183e41f4b71Sopenharmony_ci## Running the Test Script
184e41f4b71Sopenharmony_ci
185e41f4b71Sopenharmony_ci### In DevEco Studio
186e41f4b71Sopenharmony_ci
187e41f4b71Sopenharmony_ciYou can run a test script in DevEco Studio in any of the following modes:
188e41f4b71Sopenharmony_ci
189e41f4b71Sopenharmony_ci1. Test package level: All test cases in the test package are executed.
190e41f4b71Sopenharmony_ci
191e41f4b71Sopenharmony_ci2. Test suite level: All test cases defined in the **describe** method are executed.
192e41f4b71Sopenharmony_ci
193e41f4b71Sopenharmony_ci3. Test method level: The specified **it** method, that is, a single test case, is executed.
194e41f4b71Sopenharmony_ci
195e41f4b71Sopenharmony_ci![](figures/Execute.PNG)
196e41f4b71Sopenharmony_ci
197e41f4b71Sopenharmony_ci**Viewing the Test Result**
198e41f4b71Sopenharmony_ci
199e41f4b71Sopenharmony_ciAfter the test is complete, you can view the test result in DevEco Studio, as shown in the following figure.
200e41f4b71Sopenharmony_ci
201e41f4b71Sopenharmony_ci![](figures/TestResult.PNG)
202e41f4b71Sopenharmony_ci
203e41f4b71Sopenharmony_ci**Viewing the Test Case Coverage**
204e41f4b71Sopenharmony_ci
205e41f4b71Sopenharmony_ciAfter the test is complete, you can view the test case coverage.
206e41f4b71Sopenharmony_ci
207e41f4b71Sopenharmony_ci### In the CLI
208e41f4b71Sopenharmony_ci
209e41f4b71Sopenharmony_ciInstall the application test package on the test device and run the **aa** command with different execution control keywords in the CLI.
210e41f4b71Sopenharmony_ci
211e41f4b71Sopenharmony_ci> **NOTE**
212e41f4b71Sopenharmony_ci>
213e41f4b71Sopenharmony_ci> Before running commands in the CLI, make sure hdc-related environment variables have been configured.
214e41f4b71Sopenharmony_ci
215e41f4b71Sopenharmony_ciThe table below lists the keywords in **aa** test commands.
216e41f4b71Sopenharmony_ci
217e41f4b71Sopenharmony_ci| Keyword | Abbreviation| Description                          | Example                      |
218e41f4b71Sopenharmony_ci| ------------- | ------------ | -------------------------------------- | ---------------------------------- |
219e41f4b71Sopenharmony_ci| --bundleName  | -b           | Application bundle name.                        | - b com.test.example               |
220e41f4b71Sopenharmony_ci| --packageName | -p           | Application module name, which is applicable to applications developed in the FA model.          | - p com.test.example.entry         |
221e41f4b71Sopenharmony_ci| --moduleName  | -m           | Application module name, which is applicable to applications developed in the stage model.       | -m entry                           |
222e41f4b71Sopenharmony_ci| NA            | -s           | \<key, value> pair.| - s unittest /ets/testrunner/OpenHarmonyTestRunner |
223e41f4b71Sopenharmony_ci
224e41f4b71Sopenharmony_ciThe framework supports multiple test case execution modes, which are triggered by the key-value pair following the **-s** keyword. The table below lists the available keys and values.
225e41f4b71Sopenharmony_ci
226e41f4b71Sopenharmony_ci| Name    | Description                                                | Value                                              | Example                             |
227e41f4b71Sopenharmony_ci| ------------ | -----------------------------------------------------------------------------    | ------------------------------------------------------------ | ----------------------------------------- |
228e41f4b71Sopenharmony_ci| unittest     | **OpenHarmonyTestRunner** object used for test case execution. | **OpenHarmonyTestRunner** or custom runner name.                 | - s unittest OpenHarmonyTestRunner        |
229e41f4b71Sopenharmony_ci| class        | Test suite or test case to be executed.                                  | {describeName}#{itName}, {describeName}                     | -s class attributeTest#testAttributeIt    |
230e41f4b71Sopenharmony_ci| notClass     | Test suite or test case that does not need to be executed.                              | {describeName}#{itName}, {describeName}                     | -s notClass attributeTest#testAttributeIt |
231e41f4b71Sopenharmony_ci| itName       | Test case to be executed.                                        | {itName}                                                     | -s itName testAttributeIt                 |
232e41f4b71Sopenharmony_ci| timeout      | Timeout interval for executing a test case.                                       | Positive integer (unit: ms). If no value is set, the default value **5000** is used.                       | -s timeout 15000                          |
233e41f4b71Sopenharmony_ci| breakOnError | Whether to enable break-on-error mode. When this mode is enabled, the test execution process exits if a test assertion failure or error occurs.| **true**/**false** (default value)                                          | -s breakOnError true                      |
234e41f4b71Sopenharmony_ci| random | Whether to execute test cases in random sequence.| **true**/**false** (default value)                                          | -s random true                      |
235e41f4b71Sopenharmony_ci| testType     | Type of the test case to be executed.                                     | function, performance, power, reliability, security, global, compatibility, user, standard, safety, resilience| -s testType function                      |
236e41f4b71Sopenharmony_ci| level        | Level of the test case to be executed.                                     | 0, 1, 2, 3, 4                                                   | -s level 0                                |
237e41f4b71Sopenharmony_ci| size         | Size of the test case to be executed.                                   | small, medium, large                                        | -s size small        
238e41f4b71Sopenharmony_ci| stress       | Number of times that the test case is executed.                                   |  Positive integer                                        | -s stress 1000                            |
239e41f4b71Sopenharmony_ci
240e41f4b71Sopenharmony_ci**Running Commands**
241e41f4b71Sopenharmony_ci
242e41f4b71Sopenharmony_ci- Parameter configuration and commands are based on the stage model.
243e41f4b71Sopenharmony_ci- Open the CLI.
244e41f4b71Sopenharmony_ci- Run the **aa test** commands.
245e41f4b71Sopenharmony_ci
246e41f4b71Sopenharmony_ci
247e41f4b71Sopenharmony_ciExample 1: Execute all test cases.
248e41f4b71Sopenharmony_ci
249e41f4b71Sopenharmony_ci```shell  
250e41f4b71Sopenharmony_ci hdc shell aa test -b xxx -m xxx -s unittest OpenHarmonyTestRunner
251e41f4b71Sopenharmony_ci```
252e41f4b71Sopenharmony_ci
253e41f4b71Sopenharmony_ciExample 2: Execute cases in the specified test suites, separated by commas (,).
254e41f4b71Sopenharmony_ci
255e41f4b71Sopenharmony_ci```shell  
256e41f4b71Sopenharmony_ci  hdc shell aa test -b xxx -m xxx -s unittest OpenHarmonyTestRunner -s class s1,s2
257e41f4b71Sopenharmony_ci```
258e41f4b71Sopenharmony_ci
259e41f4b71Sopenharmony_ciExample 3: Execute specified cases in the specified test suites, separated by commas (,).
260e41f4b71Sopenharmony_ci
261e41f4b71Sopenharmony_ci```shell  
262e41f4b71Sopenharmony_ci  hdc shell aa test -b xxx -m xxx -s unittest OpenHarmonyTestRunner -s class testStop#stop_1,testStop1#stop_0
263e41f4b71Sopenharmony_ci```
264e41f4b71Sopenharmony_ci
265e41f4b71Sopenharmony_ciExample 4: Execute all test cases except the specified ones, separated by commas (,).
266e41f4b71Sopenharmony_ci
267e41f4b71Sopenharmony_ci```shell  
268e41f4b71Sopenharmony_ci  hdc shell aa test -b xxx -m xxx -s unittest OpenHarmonyTestRunner -s notClass testStop
269e41f4b71Sopenharmony_ci```
270e41f4b71Sopenharmony_ci
271e41f4b71Sopenharmony_ciExample 5: Execute specified test cases, separated by commas (,).
272e41f4b71Sopenharmony_ci
273e41f4b71Sopenharmony_ci```shell  
274e41f4b71Sopenharmony_ci  hdc shell aa test -b xxx -m xxx -s unittest OpenHarmonyTestRunner -s itName stop_0
275e41f4b71Sopenharmony_ci```
276e41f4b71Sopenharmony_ci
277e41f4b71Sopenharmony_ciExample 6: Set the timeout interval for executing a test case.
278e41f4b71Sopenharmony_ci
279e41f4b71Sopenharmony_ci```shell  
280e41f4b71Sopenharmony_ci  hdc shell aa test -b xxx -m xxx -s unittest OpenHarmonyTestRunner -s timeout 15000
281e41f4b71Sopenharmony_ci```
282e41f4b71Sopenharmony_ci
283e41f4b71Sopenharmony_ciExample 7: Enable break-on-error mode.
284e41f4b71Sopenharmony_ci
285e41f4b71Sopenharmony_ci```shell  
286e41f4b71Sopenharmony_ci  hdc shell aa test -b xxx -m xxx -s unittest OpenHarmonyTestRunner -s breakOnError true
287e41f4b71Sopenharmony_ci```
288e41f4b71Sopenharmony_ci
289e41f4b71Sopenharmony_ciExample 8: Execute test cases of the specified type.
290e41f4b71Sopenharmony_ci
291e41f4b71Sopenharmony_ci```shell  
292e41f4b71Sopenharmony_ci  hdc shell aa test -b xxx -m xxx -s unittest OpenHarmonyTestRunner -s testType function
293e41f4b71Sopenharmony_ci```
294e41f4b71Sopenharmony_ci
295e41f4b71Sopenharmony_ciExample 9: Execute test cases at the specified level.
296e41f4b71Sopenharmony_ci
297e41f4b71Sopenharmony_ci```shell  
298e41f4b71Sopenharmony_ci  hdc shell aa test -b xxx -m xxx -s unittest OpenHarmonyTestRunner -s level 0
299e41f4b71Sopenharmony_ci```
300e41f4b71Sopenharmony_ci
301e41f4b71Sopenharmony_ciExample 10: Execute test cases with the specified size.
302e41f4b71Sopenharmony_ci
303e41f4b71Sopenharmony_ci```shell  
304e41f4b71Sopenharmony_ci  hdc shell aa test -b xxx -m xxx -s unittest OpenHarmonyTestRunner -s size small
305e41f4b71Sopenharmony_ci```
306e41f4b71Sopenharmony_ci
307e41f4b71Sopenharmony_ciExample 11: Execute test cases for a specified number of times.
308e41f4b71Sopenharmony_ci
309e41f4b71Sopenharmony_ci```shell  
310e41f4b71Sopenharmony_ci  hdc shell aa test -b xxx -m xxx -s unittest OpenHarmonyTestRunner -s stress 1000
311e41f4b71Sopenharmony_ci```
312e41f4b71Sopenharmony_ci
313e41f4b71Sopenharmony_ci**Viewing the Test Result**
314e41f4b71Sopenharmony_ci
315e41f4b71Sopenharmony_ci- During test execution in the CLI, the log information similar to the following is displayed:
316e41f4b71Sopenharmony_ci
317e41f4b71Sopenharmony_ci```
318e41f4b71Sopenharmony_ciOHOS_REPORT_STATUS: class=testStop
319e41f4b71Sopenharmony_ciOHOS_REPORT_STATUS: current=1
320e41f4b71Sopenharmony_ciOHOS_REPORT_STATUS: id=JS
321e41f4b71Sopenharmony_ciOHOS_REPORT_STATUS: numtests=447
322e41f4b71Sopenharmony_ciOHOS_REPORT_STATUS: stream=
323e41f4b71Sopenharmony_ciOHOS_REPORT_STATUS: test=stop_0
324e41f4b71Sopenharmony_ciOHOS_REPORT_STATUS_CODE: 1
325e41f4b71Sopenharmony_ci
326e41f4b71Sopenharmony_ciOHOS_REPORT_STATUS: class=testStop
327e41f4b71Sopenharmony_ciOHOS_REPORT_STATUS: current=1
328e41f4b71Sopenharmony_ciOHOS_REPORT_STATUS: id=JS
329e41f4b71Sopenharmony_ciOHOS_REPORT_STATUS: numtests=447
330e41f4b71Sopenharmony_ciOHOS_REPORT_STATUS: stream=
331e41f4b71Sopenharmony_ciOHOS_REPORT_STATUS: test=stop_0
332e41f4b71Sopenharmony_ciOHOS_REPORT_STATUS_CODE: 0
333e41f4b71Sopenharmony_ciOHOS_REPORT_STATUS: consuming=4
334e41f4b71Sopenharmony_ci```
335e41f4b71Sopenharmony_ci
336e41f4b71Sopenharmony_ci| Log Field              | Description      |
337e41f4b71Sopenharmony_ci| -------           | -------------------------|
338e41f4b71Sopenharmony_ci| OHOS_REPORT_SUM    | Total number of test cases in the current test suite.|
339e41f4b71Sopenharmony_ci| OHOS_REPORT_STATUS: class | Name of the test suite that is being executed.|
340e41f4b71Sopenharmony_ci| OHOS_REPORT_STATUS: id | Case execution language. The default value is JS. |
341e41f4b71Sopenharmony_ci| OHOS_REPORT_STATUS: numtests | Total number of test cases in the test package.|
342e41f4b71Sopenharmony_ci| OHOS_REPORT_STATUS: stream | Error information of the current test case.|
343e41f4b71Sopenharmony_ci| OHOS_REPORT_STATUS: test| Name of the current test case.|
344e41f4b71Sopenharmony_ci| OHOS_REPORT_STATUS_CODE | Execution result of the current test case.<br>**0**: pass.<br>**1**: error.<br>**2**: fail.|
345e41f4b71Sopenharmony_ci| OHOS_REPORT_STATUS: consuming | Time spent in executing the current test case, in milliseconds.|
346e41f4b71Sopenharmony_ci
347e41f4b71Sopenharmony_ci- After the commands are executed, the following log information is displayed:
348e41f4b71Sopenharmony_ci
349e41f4b71Sopenharmony_ci```
350e41f4b71Sopenharmony_ciOHOS_REPORT_RESULT: stream=Tests run: 447, Failure: 0, Error: 1, Pass: 201, Ignore: 245
351e41f4b71Sopenharmony_ciOHOS_REPORT_CODE: 0
352e41f4b71Sopenharmony_ci
353e41f4b71Sopenharmony_ciOHOS_REPORT_RESULT: breakOnError model, Stopping whole test suite if one specific test case failed or error
354e41f4b71Sopenharmony_ciOHOS_REPORT_STATUS: taskconsuming=16029
355e41f4b71Sopenharmony_ci
356e41f4b71Sopenharmony_ci```
357e41f4b71Sopenharmony_ci| Log Field              | Description          |
358e41f4b71Sopenharmony_ci| ------------------| -------------------------|
359e41f4b71Sopenharmony_ci| run    | Total number of test cases in the current test package.|
360e41f4b71Sopenharmony_ci| Failure | Number of failed test cases.|
361e41f4b71Sopenharmony_ci| Error | Number of test cases whose execution encounters errors. |
362e41f4b71Sopenharmony_ci| Pass | Number of passed test cases.|
363e41f4b71Sopenharmony_ci| Ignore | Number of test cases not yet executed.|
364e41f4b71Sopenharmony_ci| taskconsuming| Total time spent in executing the current test case, in milliseconds.|
365e41f4b71Sopenharmony_ci
366e41f4b71Sopenharmony_ci> When an error occurs in break-on-error mode, check the **Ignore** and interrupt information.
367e41f4b71Sopenharmony_ci
368e41f4b71Sopenharmony_ci## Recording User Operations
369e41f4b71Sopenharmony_ci### Using the Recording Feature
370e41f4b71Sopenharmony_ci> You can record the operations performed on the current page to **/data/local/tmp/layout/record.csv**. To end the recording, press **Ctrl+C**.
371e41f4b71Sopenharmony_ci
372e41f4b71Sopenharmony_ci```shell  
373e41f4b71Sopenharmony_ci hdc shell uitest uiRecord record
374e41f4b71Sopenharmony_ci```
375e41f4b71Sopenharmony_ci### Viewing Recording Data
376e41f4b71Sopenharmony_ciYou can view the recording data in either of the following ways.
377e41f4b71Sopenharmony_ci
378e41f4b71Sopenharmony_ci#### Reading and Printing Recording Data
379e41f4b71Sopenharmony_ci
380e41f4b71Sopenharmony_ci```shell  
381e41f4b71Sopenharmony_ci hdc shell uitest uiRecord read
382e41f4b71Sopenharmony_ci```
383e41f4b71Sopenharmony_ci#### Exporting the record.csv File
384e41f4b71Sopenharmony_ci```shell  
385e41f4b71Sopenharmony_cihdc file recv /data/local/tmp/layout/record.csv D:\tool  # D:\tool indicates the local save path, which can be customized.
386e41f4b71Sopenharmony_ci```
387e41f4b71Sopenharmony_ci- The following describes the fields in the recording data:
388e41f4b71Sopenharmony_ci```
389e41f4b71Sopenharmony_ci{
390e41f4b71Sopenharmony_ci	"ABILITY": "com.ohos.launcher.MainAbility", // Foreground application page.
391e41f4b71Sopenharmony_ci	"BUNDLE": "com.ohos.launcher", // Application.
392e41f4b71Sopenharmony_ci	"CENTER_X": "", // Reserved field.
393e41f4b71Sopenharmony_ci	"CENTER_Y": "", // Reserved field.
394e41f4b71Sopenharmony_ci	"EVENT_TYPE": "pointer", //  
395e41f4b71Sopenharmony_ci	"LENGTH": "0", // Total length.
396e41f4b71Sopenharmony_ci	"OP_TYPE": "click", // Event type. Currently, click, double-click, long-press, drag, pinch, swipe, and fling types are supported.
397e41f4b71Sopenharmony_ci	"VELO": "0.000000", // Hands-off velocity.
398e41f4b71Sopenharmony_ci	"direction.X": "0.000000",// Movement along the x-axis.
399e41f4b71Sopenharmony_ci	"direction.Y": "0.000000", // Movement along the y-axis.
400e41f4b71Sopenharmony_ci	"duration": 33885000.0, // Gesture duration.
401e41f4b71Sopenharmony_ci	"fingerList": [{
402e41f4b71Sopenharmony_ci		"LENGTH": "0", // Total length.
403e41f4b71Sopenharmony_ci		"MAX_VEL": "40000", // Maximum velocity.
404e41f4b71Sopenharmony_ci		"VELO": "0.000000", // Hands-off velocity.
405e41f4b71Sopenharmony_ci		"W1_BOUNDS": "{"bottom":361,"left":37,"right":118,"top":280}", // Starting component bounds.
406e41f4b71Sopenharmony_ci		"W1_HIER": "ROOT,3,0,0,0,0,0,0,0,0,0,0,5,0,0,0,0,0,0,0,0", // Starting component hierarchy.
407e41f4b71Sopenharmony_ci		"W1_ID": "", // ID of the starting component.
408e41f4b71Sopenharmony_ci		"W1_Text": "", // Text of the starting component.
409e41f4b71Sopenharmony_ci		"W1_Type": "Image", // Type of the starting component.
410e41f4b71Sopenharmony_ci		"W2_BOUNDS": "{"bottom":361,"left":37,"right":118,"top":280}", // Ending component bounds.
411e41f4b71Sopenharmony_ci		"W2_HIER": "ROOT,3,0,0,0,0,0,0,0,0,5,0,0,0,0,0,0,0", // Ending component hierarchy.
412e41f4b71Sopenharmony_ci		"W2_ID": "", // ID of the ending component.
413e41f4b71Sopenharmony_ci		"W2_Text": "", // Text of the ending component.
414e41f4b71Sopenharmony_ci		"W2_Type": "Image", // Type of the ending component.
415e41f4b71Sopenharmony_ci		"X2_POSI": "47", // X coordinate of the ending point.
416e41f4b71Sopenharmony_ci		"X_POSI": "47", // X coordinate of the starting point.
417e41f4b71Sopenharmony_ci		"Y2_POSI": "301", // Y coordinate of the ending point.
418e41f4b71Sopenharmony_ci		"Y_POSI": "301", // Y coordinate of the starting point.
419e41f4b71Sopenharmony_ci		"direction.X": "0.000000", // Movement along the x-axis.
420e41f4b71Sopenharmony_ci		"direction.Y": "0.000000" // Movement along the y-axis.
421e41f4b71Sopenharmony_ci	}],
422e41f4b71Sopenharmony_ci	"fingerNumber": "1" // Number of fingers.
423e41f4b71Sopenharmony_ci}
424e41f4b71Sopenharmony_ci```
425e41f4b71Sopenharmony_ci
426e41f4b71Sopenharmony_ci## Injecting Simulated UI Operations in Shell Command Mode
427e41f4b71Sopenharmony_ci> Supported operation types: click, double-click, long press, fling, swipe, drag, text input, and key event.
428e41f4b71Sopenharmony_ci
429e41f4b71Sopenharmony_ci| Name      | Description                                 | Value                                                                                                                                                                                                               | Example                                                                                 |
430e41f4b71Sopenharmony_ci|-------------|-----------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------|
431e41f4b71Sopenharmony_ci| click       | Simulates a click.                                 | point_x (X coordinate of the click point. Mandatory.)<br> point_y (Y coordinate of the click point. Mandatory.)                                                                                                                                                                     | hdc shell uitest uiInput click point_x point_y                                      |
432e41f4b71Sopenharmony_ci| doubleClick | Simulates a double-click.                                 | point_x (X coordinate of the double-click point. Mandatory.)<br> point_y (Y coordinate of the double-click point. Mandatory.)                                                                                                                                                                     | hdc shell uitest uiInput doubleClick point_x point_y                                |
433e41f4b71Sopenharmony_ci| longClick   | Simulates a long-click.                                 | point_x (X coordinate of the long-click point. Mandatory.)<br> point_y (Y coordinate of the long-click point. Mandatory.)                                                                                                                                                                     | hdc shell uitest uiInput longClick point_x point_y                                  |
434e41f4b71Sopenharmony_ci| fling       | Simulates a fling.                                 | from_x (X coordinate of the fling start point. Mandatory.)<br> from_y (Y coordinate of the fling start point. Mandatory.)<br> to_x (X coordinate of the fling end point. Mandatory.)<br> to_y (Y coordinate of the fling end point. Mandatory.)<br> swipeVelocityPps_ (Fling speed. Value range: 200-40000. Default value: 600. Optional.)<br> stepLength (Fling step. Default value: Fling distance/50. Unit: px. Optional.)| hdc shell uitest uiInput fling from_x from_y to_x to_y swipeVelocityPps_ stepLength |
435e41f4b71Sopenharmony_ci| swipe       | Simulates a swipe.                                 | from_x (X coordinate of the swipe start point. Mandatory.)<br> from_y (Y coordinate of the swipe start point. Mandatory.)<br> to_x (X coordinate of the swipe end point. Mandatory.)<br> to_y (Y coordinate of the swipe end point. Mandatory.)<br> swipeVelocityPps_ (Fling speed. Value range: 200-40000. Default value: 600. Unit: px/s. Optional.)                                              | hdc shell uitest uiInput swipe from_x from_y to_x to_y swipeVelocityPps_            |
436e41f4b71Sopenharmony_ci| drag        | Simulates a drag and drop.                                 | from_x (X coordinate of the drag point. Mandatory.)<br> from_y (Y coordinate of the drag point. Mandatory.)<br> to_x (X coordinate of the drop point. Mandatory.)<br> to_y (Y coordinate of the drop point. Mandatory.)<br> swipeVelocityPps_ (Drag speed. Value range: 200-40000. Default value: 600. Unit: px/s. Optional.)                                      | hdc shell uitest uiInput drag from_x from_y to_x to_y swipeVelocityPps_             |
437e41f4b71Sopenharmony_ci| dircFling   | Simulates a directional fling.                             | direction (Fling direction. Value range: [0, 1, 2, 3]. Fling direction: [left, right, up, down]. Default value: 0. Optional.)<br> swipeVelocityPps_ (Fling speed. Value range: 200-40000. Default value: 600. Optional.)<br> stepLength (Fling step. Default value: Fling distance/50. Unit: px. Optional.)                                           | hdc shell uitest uiInput dircFling direction swipeVelocityPps_ stepLength                                       |
438e41f4b71Sopenharmony_ci| inputText        | Simulates text input in a text box.                            | point_x (X coordinate of the text box. Mandatory.)<br> point_y (Y coordinate of the text box. Mandatory.)<br> input (Text entered.)                                                                                                                                                  | hdc shell uitest uiInput inputText  point_x point_y text                                  |
439e41f4b71Sopenharmony_ci| keyEvent    | Simulates a physical key event (such as pressing a keyboard key, pressing the power key, returning to the previous page, or returning to the home screen) or a key combination.| keyID (ID of a physical key. Mandatory.)<br> keyID2 (ID of a physical key. Optional.)                                                                                                                                                                    | hdc shell uitest uiInput keyEvent keyID                                             |
440e41f4b71Sopenharmony_ci
441e41f4b71Sopenharmony_ciExample 1: Perform a click.
442e41f4b71Sopenharmony_ci```shell  
443e41f4b71Sopenharmony_ci hdc shell uitest uiInput click 100 100
444e41f4b71Sopenharmony_ci```
445e41f4b71Sopenharmony_ciExample 2: Perform a double-click.
446e41f4b71Sopenharmony_ci```shell  
447e41f4b71Sopenharmony_ci hdc shell uitest uiInput doubleClick 100 100
448e41f4b71Sopenharmony_ci```
449e41f4b71Sopenharmony_ciExample 3: Perform a long-click.
450e41f4b71Sopenharmony_ci```shell  
451e41f4b71Sopenharmony_ci hdc shell uitest uiInput longClick 100 100
452e41f4b71Sopenharmony_ci```
453e41f4b71Sopenharmony_ciExample 4: Perform a fling.
454e41f4b71Sopenharmony_ci```shell  
455e41f4b71Sopenharmony_cihdc shell uitest uiInput fling 10 10 200 200 500 
456e41f4b71Sopenharmony_ci```
457e41f4b71Sopenharmony_ciExample 5: Perform a swipe.
458e41f4b71Sopenharmony_ci```shell  
459e41f4b71Sopenharmony_cihdc shell uitest uiInput swipe 10 10 200 200 500 
460e41f4b71Sopenharmony_ci```
461e41f4b71Sopenharmony_ciExample 6: Perform a drag and drop.
462e41f4b71Sopenharmony_ci```shell  
463e41f4b71Sopenharmony_cihdc shell uitest uiInput drag 10 10 100 100 500 
464e41f4b71Sopenharmony_ci```
465e41f4b71Sopenharmony_ciExample 7: Perform a fling-left.
466e41f4b71Sopenharmony_ci```shell  
467e41f4b71Sopenharmony_cihdc shell uitest uiInput dircFling 0 500
468e41f4b71Sopenharmony_ci```
469e41f4b71Sopenharmony_ciExample 8: Perform a fling-right.
470e41f4b71Sopenharmony_ci```shell  
471e41f4b71Sopenharmony_cihdc shell uitest uiInput dircFling 1 600
472e41f4b71Sopenharmony_ci```
473e41f4b71Sopenharmony_ciExample 9: Perform a fling-up.
474e41f4b71Sopenharmony_ci```shell  
475e41f4b71Sopenharmony_cihdc shell uitest uiInput dircFling 2 
476e41f4b71Sopenharmony_ci```
477e41f4b71Sopenharmony_ciExample 10: Perform a fling-down.
478e41f4b71Sopenharmony_ci```shell  
479e41f4b71Sopenharmony_cihdc shell uitest uiInput dircFling 3
480e41f4b71Sopenharmony_ci```
481e41f4b71Sopenharmony_ci
482e41f4b71Sopenharmony_ciExample 11: Enter text in the text box.
483e41f4b71Sopenharmony_ci```shell  
484e41f4b71Sopenharmony_cihdc shell uitest uiInput inputText 100 100 hello
485e41f4b71Sopenharmony_ci```
486e41f4b71Sopenharmony_ci
487e41f4b71Sopenharmony_ciExample 12: Return to the home screen.
488e41f4b71Sopenharmony_ci```shell  
489e41f4b71Sopenharmony_cihdc shell uitest uiInput keyEvent Home
490e41f4b71Sopenharmony_ci```
491e41f4b71Sopenharmony_ciExample 13: Return to the previous page.
492e41f4b71Sopenharmony_ci```shell  
493e41f4b71Sopenharmony_cihdc shell uitest uiInput keyEvent Back
494e41f4b71Sopenharmony_ci```
495e41f4b71Sopenharmony_ciExample 14: Perform a key combination to copy and paste text.
496e41f4b71Sopenharmony_ci```shell  
497e41f4b71Sopenharmony_cihdc shell uitest uiInput keyEvent 2072 2038
498e41f4b71Sopenharmony_ci```
499e41f4b71Sopenharmony_ci
500e41f4b71Sopenharmony_ci<!--Del-->
501e41f4b71Sopenharmony_ci## Examples
502e41f4b71Sopenharmony_ci
503e41f4b71Sopenharmony_ci### Unit Test Scripts
504e41f4b71Sopenharmony_ci
505e41f4b71Sopenharmony_ci#### Using Assertion APIs of the Unit Test
506e41f4b71Sopenharmony_ciFor details about how to use the available APIs, see [Example of Using Assertion APIs](https://gitee.com/openharmony/applications_app_samples/blob/master/code/Project/Test/jsunit/entry/src/ohosTest/ets/test/assertExampleTest/assertExample.test.ets).
507e41f4b71Sopenharmony_ci
508e41f4b71Sopenharmony_ci#### Defining Unit Test Suites
509e41f4b71Sopenharmony_ciFor details about how to define and nest the unit test suite, see [Example of Defining Test Suites](https://gitee.com/openharmony/applications_app_samples/blob/master/code/Project/Test/jsunit/entry/src/ohosTest/ets/test/coverExampleTest/coverExample.test.ets).
510e41f4b71Sopenharmony_ci
511e41f4b71Sopenharmony_ci#### Testing Custom Application Functions Using Unit Test
512e41f4b71Sopenharmony_ciFor details about how to test the custom functions in an application, see [Example of Testing Custom Application Functions](https://gitee.com/openharmony/applications_app_samples/blob/master/code/Project/Test/jsunit/entry/src/ohosTest/ets/test/customExampleTest/customExample.test.ets).
513e41f4b71Sopenharmony_ci
514e41f4b71Sopenharmony_ci#### Using Data-Driven Capability of the Unit Test
515e41f4b71Sopenharmony_ciFor details about how to use the data-driven capability and configure repeat script execution, see [Example of Using Data-Driven Capability](https://gitee.com/openharmony/applications_app_samples/blob/master/code/Project/Test/jsunit/entry/src/ohosTest/ets/test/paramExampleTest/paramExample.test.ets).
516e41f4b71Sopenharmony_ci
517e41f4b71Sopenharmony_ci### UI Test Scripts for Components
518e41f4b71Sopenharmony_ci
519e41f4b71Sopenharmony_ci#### Searching for Specified Components
520e41f4b71Sopenharmony_ciFor details about how to search for a component in an application UI by specifying the attributes of the component, see [Example of Searching for Specified Components](https://gitee.com/openharmony/applications_app_samples/blob/master/code/Project/Test/uitest/entry/src/ohosTest/ets/test/findCommentExampleTest/Component/findCommentExample.test.ets).
521e41f4b71Sopenharmony_ci
522e41f4b71Sopenharmony_ci#### Simulating Click Events
523e41f4b71Sopenharmony_ciFor details about how to simulate a click event, a long-click event or a double-click event, see [Example of Simulating Click Events](https://gitee.com/openharmony/applications_app_samples/blob/master/code/Project/Test/uitest/entry/src/ohosTest/ets/test/operationExampleTest/ui/clickEvent.test.ets).
524e41f4b71Sopenharmony_ci
525e41f4b71Sopenharmony_ci#### Simulating Mouse Events
526e41f4b71Sopenharmony_ciFor details about how to simulate a mouse left-click event, a mouse right-click event, or a mouse scroll wheel event, see [Example of Simulating Mouse Events](https://gitee.com/openharmony/applications_app_samples/blob/master/code/Project/Test/uitest/entry/src/ohosTest/ets/test/operationExampleTest/ui/MouseEvent.test.ets).
527e41f4b71Sopenharmony_ci
528e41f4b71Sopenharmony_ci#### Simulating Input Events
529e41f4b71Sopenharmony_ciFor details about how to simulate the input of Chinese and English text, see [Example of Simulating Input Events](https://gitee.com/openharmony/applications_app_samples/blob/master/code/Project/Test/uitest/entry/src/ohosTest/ets/test/operationExampleTest/ui/InputEvent.test.ets).
530e41f4b71Sopenharmony_ci
531e41f4b71Sopenharmony_ci#### Simulating Screenshot Events
532e41f4b71Sopenharmony_ciFor details about how to simulate capturing a screenshot (in a specified area), see [Example of Simulating Screenshot Events](https://gitee.com/openharmony/applications_app_samples/blob/master/code/Project/Test/uitest/entry/src/ohosTest/ets/test/operationExampleTest/ui/ScreenCapEvent.test.ets).
533e41f4b71Sopenharmony_ci
534e41f4b71Sopenharmony_ci#### Simulating Fling Events
535e41f4b71Sopenharmony_ciFor details about how to simulate a fling event(the finger leaves the screen after sliding), see [Example of Simulating Fling Events](https://gitee.com/openharmony/applications_app_samples/blob/master/code/Project/Test/uitest/entry/src/ohosTest/ets/test/operationExampleTest/ui/FlingEvent.test.ets).
536e41f4b71Sopenharmony_ci
537e41f4b71Sopenharmony_ci#### Simulating Swipe Events
538e41f4b71Sopenharmony_ciFor details about how to simulate a swipe event (the finger stays on the screen after sliding), see [Example of Simulating Swipe Events](https://gitee.com/openharmony/applications_app_samples/blob/master/code/Project/Test/uitest/entry/src/ohosTest/ets/test/operationExampleTest/ui/SwipeEvent.test.ets).
539e41f4b71Sopenharmony_ci
540e41f4b71Sopenharmony_ci#### Simulating Pinch Events
541e41f4b71Sopenharmony_ciFor details about how to simulate a zoom-in and zoom-out operation on pictures, see [Example of Simulating Pinch Events](https://gitee.com/openharmony/applications_app_samples/blob/master/code/Project/Test/uitest/entry/src/ohosTest/ets/test/operationExampleTest/ui/PinchEvent.test.ets).
542e41f4b71Sopenharmony_ci
543e41f4b71Sopenharmony_ci#### Simulating Scroll Events
544e41f4b71Sopenharmony_ciFor details about how to simulate components scrolling, see [Example of Simulating Scroll Events](https://gitee.com/openharmony/applications_app_samples/blob/master/code/Project/Test/uitest/entry/src/ohosTest/ets/test/operationExampleTest/ui/ScrollerEvent.test.ets).
545e41f4b71Sopenharmony_ci
546e41f4b71Sopenharmony_ci### UI Test Scripts for Windows
547e41f4b71Sopenharmony_ci
548e41f4b71Sopenharmony_ci#### Searching for Specified Windows
549e41f4b71Sopenharmony_ciFor details about how to search for an application window by using the bundle name of the application, see [Example of Searching for Specified Windows](https://gitee.com/openharmony/applications_app_samples/blob/master/code/Project/Test/uitest/entry/src/ohosTest/ets/test/findCommentExampleTest/window/findWindowExample.test.ets).
550e41f4b71Sopenharmony_ci
551e41f4b71Sopenharmony_ci#### Simulating Window Move Events
552e41f4b71Sopenharmony_ciFor details about how to simulate moving a window to a specified position, see [Example of Simulating Window Move Events](https://gitee.com/openharmony/applications_app_samples/blob/master/code/Project/Test/uitest/entry/src/ohosTest/ets/test/operationExampleTest/window/MoveToEvent.test.ets).
553e41f4b71Sopenharmony_ci
554e41f4b71Sopenharmony_ci#### Simulating Window Size Adjustments
555e41f4b71Sopenharmony_ciFor details about how to simulate a window size adjustment and direction specification, see [Example of Simulating Window Size Adjustments](https://gitee.com/openharmony/applications_app_samples/blob/master/code/Project/Test/uitest/entry/src/ohosTest/ets/test/operationExampleTest/window/ReSizeWindow.test.ets).
556e41f4b71Sopenharmony_ci
557e41f4b71Sopenharmony_ci<!--DelEnd-->
558e41f4b71Sopenharmony_ci
559e41f4b71Sopenharmony_ci## FAQs
560e41f4b71Sopenharmony_ci
561e41f4b71Sopenharmony_ci### FAQs About Unit Test Cases
562e41f4b71Sopenharmony_ci
563e41f4b71Sopenharmony_ci**The logs in the test case are printed after the test case result**
564e41f4b71Sopenharmony_ci
565e41f4b71Sopenharmony_ci**Problem**
566e41f4b71Sopenharmony_ci
567e41f4b71Sopenharmony_ciThe logs added to the test case are displayed after the test case execution, rather than during the test case execution.
568e41f4b71Sopenharmony_ci
569e41f4b71Sopenharmony_ci**Possible Causes**
570e41f4b71Sopenharmony_ci
571e41f4b71Sopenharmony_ciMore than one asynchronous API is called in the test case.<br>In principle, logs in the test case are printed before the test case execution is complete.
572e41f4b71Sopenharmony_ci
573e41f4b71Sopenharmony_ci**Solutions**
574e41f4b71Sopenharmony_ci
575e41f4b71Sopenharmony_ciIf more than one asynchronous API is called, you are advised to encapsulate the API invoking into the promise mode.
576e41f4b71Sopenharmony_ci
577e41f4b71Sopenharmony_ci**Error "fail to start ability" is reported during test case execution**
578e41f4b71Sopenharmony_ci
579e41f4b71Sopenharmony_ci**Problem**
580e41f4b71Sopenharmony_ci
581e41f4b71Sopenharmony_ciWhen a test case is executed, the console returns the error message "fail to start ability".
582e41f4b71Sopenharmony_ci
583e41f4b71Sopenharmony_ci**Possible Causes**
584e41f4b71Sopenharmony_ci
585e41f4b71Sopenharmony_ciAn error occurs during the packaging of the test package, and the test framework dependency file is not included in the test package.
586e41f4b71Sopenharmony_ci
587e41f4b71Sopenharmony_ci**Solutions**
588e41f4b71Sopenharmony_ci
589e41f4b71Sopenharmony_ciCheck whether the test package contains the **OpenHarmonyTestRunner.abc** file. If the file does not exist, rebuild and pack the file and perform the test again.
590e41f4b71Sopenharmony_ci
591e41f4b71Sopenharmony_ci**Test case execution timeout**
592e41f4b71Sopenharmony_ci
593e41f4b71Sopenharmony_ci**Problem**
594e41f4b71Sopenharmony_ci
595e41f4b71Sopenharmony_ciAfter the test case execution is complete, the console displays the error message "execute time XXms", indicating that the case execution times out.
596e41f4b71Sopenharmony_ci
597e41f4b71Sopenharmony_ci**Possible Causes**
598e41f4b71Sopenharmony_ci
599e41f4b71Sopenharmony_ci1. The test case is executed through an asynchronous interface, but the **done** function is not executed during the execution. As a result, the test case execution does not end until it times out.
600e41f4b71Sopenharmony_ci
601e41f4b71Sopenharmony_ci2. The time taken for API invocation is longer than the timeout interval set for test case execution.
602e41f4b71Sopenharmony_ci
603e41f4b71Sopenharmony_ci3. Test assertion fails, and a failure exception is thrown. As a result, the test case execution does not end until it times out.
604e41f4b71Sopenharmony_ci
605e41f4b71Sopenharmony_ci**Solutions**
606e41f4b71Sopenharmony_ci
607e41f4b71Sopenharmony_ci1. Check the code logic of the test case to ensure that the **done** function is executed even if the assertion fails.
608e41f4b71Sopenharmony_ci
609e41f4b71Sopenharmony_ci2. Modify the case execution timeout settings under **Run/Debug Configurations** in DevEco Studio.
610e41f4b71Sopenharmony_ci
611e41f4b71Sopenharmony_ci3. Check the code logic and assertion result of the test case and make sure that the assertion is passed.
612e41f4b71Sopenharmony_ci### FAQs About UI Test Cases
613e41f4b71Sopenharmony_ci
614e41f4b71Sopenharmony_ci**The failure log contains "Get windows failed/GetRootByWindow failed"**
615e41f4b71Sopenharmony_ci
616e41f4b71Sopenharmony_ci**Problem**
617e41f4b71Sopenharmony_ci
618e41f4b71Sopenharmony_ciThe UI test case fails to be executed. The HiLog file contains the error message "Get windows failed/GetRootByWindow failed."
619e41f4b71Sopenharmony_ci
620e41f4b71Sopenharmony_ci**Possible Causes**
621e41f4b71Sopenharmony_ci
622e41f4b71Sopenharmony_ciThe ArkUI feature is disabled. As a result, the component tree information is not generated on the test page.
623e41f4b71Sopenharmony_ci
624e41f4b71Sopenharmony_ci**Solutions**
625e41f4b71Sopenharmony_ci
626e41f4b71Sopenharmony_ciRun the following command, restart the device, and execute the test case again:
627e41f4b71Sopenharmony_ci
628e41f4b71Sopenharmony_ci```shell
629e41f4b71Sopenharmony_cihdc shell param set persist.ace.testmode.enabled 1
630e41f4b71Sopenharmony_ci```
631e41f4b71Sopenharmony_ci
632e41f4b71Sopenharmony_ci**The failure log contains "uitest-api does not allow calling concurrently"**
633e41f4b71Sopenharmony_ci
634e41f4b71Sopenharmony_ci**Problem**
635e41f4b71Sopenharmony_ci
636e41f4b71Sopenharmony_ciThe UI test case fails to be executed. The HiLog file contains the error message "uitest-api does not allow calling concurrently."
637e41f4b71Sopenharmony_ci
638e41f4b71Sopenharmony_ci**Possible Causes**
639e41f4b71Sopenharmony_ci
640e41f4b71Sopenharmony_ci1. In the test case, the **await** operator is not added to the asynchronous API provided by the UI test framework.
641e41f4b71Sopenharmony_ci
642e41f4b71Sopenharmony_ci2. The UI test case is executed in multiple processes. As a result, multiple UI test processes are started. The framework does not support multi-process invoking.
643e41f4b71Sopenharmony_ci
644e41f4b71Sopenharmony_ci**Solutions**
645e41f4b71Sopenharmony_ci
646e41f4b71Sopenharmony_ci1. Check the case implementation and add the **await** operator to the asynchronous API.
647e41f4b71Sopenharmony_ci
648e41f4b71Sopenharmony_ci2. Do not execute UI test cases in multiple processes.
649e41f4b71Sopenharmony_ci
650e41f4b71Sopenharmony_ci**The failure log contains "does not exist on current UI! Check if the UI has changed after you got the widget object"**
651e41f4b71Sopenharmony_ci
652e41f4b71Sopenharmony_ci**Problem**
653e41f4b71Sopenharmony_ci
654e41f4b71Sopenharmony_ciThe UI test case fails to be executed. The HiLog file contains the error message "does not exist on current UI! Check if the UI has changed after you got the widget object."
655e41f4b71Sopenharmony_ci
656e41f4b71Sopenharmony_ci**Possible Causes**
657e41f4b71Sopenharmony_ci
658e41f4b71Sopenharmony_ciAfter the target component is found in the code of the test case, the device UI changes, resulting in loss of the found component and inability to perform emulation.
659e41f4b71Sopenharmony_ci
660e41f4b71Sopenharmony_ci**Solutions**
661e41f4b71Sopenharmony_ci
662e41f4b71Sopenharmony_ciRun the UI test case again.
663