• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Test
2OpenHarmony provides a comprehensive auto-test framework for designing test cases. Detecting defects in the development process can improve code quality.
3
4This document describes how to use the OpenHarmony test framework.
5## Setting Up the Environment
6The test framework depends on Python. Before using the test framework, set up the environment as follows:
7 - [Setting Up the Environment](../device-dev/subsystems/subsys-testguide-envbuild.md)
8 - [Obtaining Source Code](../device-dev/get-code/sourcecode-acquire.md)
9
10
11## Directory Structure
12The directory structure of the test framework is as follows:
13```
14test # Test subsystem
15├── developertest             # Developer test component
16│   ├── aw                    # Static library of the test framework
17│   ├── config                # Test framework configuration
18│   │   │ ...
19│   │   └── user_config.xml   # User configuration
20│   ├── examples              # Test case examples
21│   ├── src                   # Source code of the test framework
22│   ├── third_party           # Adaptation code for third-party components on which the test framework depends
23│   ├── reports               # Test reports
24│   ├── BUILD.gn              # Build entry of the test framework
25│   ├── start.bat             # Test entry for Windows
26│   └── start.sh              # Test entry for Linux
27└── xdevice                   # Component on which the test framework depends
28```
29## Writing Test Cases
30###  Designing the Test Case Directory
31Design the test case directory as follows:
32```
33subsystem                                  # Subsystem
34├── partA                                  # Part A
35│   ├── moduleA                            # Module A
36│   │   ├── include
37│   │   ├── src                            # Service code
38│   │   └── test                           # Test directory
39│   │       ├── unittest                   # Unit tests
40│   │       │   ├── common                 # Common test cases
41│   │       │   │   ├── BUILD.gn           # Build file of test cases
42│   │       │   │   └── testA_test.cpp     # Source code of unit test cases
43│   │       │   ├── phone                  # Test cases for smart phones
44│   │       │   ├── ivi                    # Test cases for head units
45│   │       │   └── liteos-a               # Test cases for IP cameras that use the LiteOS kernel
46│   │       ├── moduletest                 # Module tests
47│   │       ...
48│   │
49│   ├── moduleB                      # Module B
50│   ├── test
51│   │   └── resource                 # Dependencies
52│   │       ├── moduleA              # Module A
53│   │       │   ├── ohos_test.xml    # Resource configuration file
54│   │       ... └── 1.txt            # Resource file
55│   │
56│   ├── ohos_build                   # Build entry configuration
57│   ...
5859...
60```
61> **NOTE**
62>
63> Test cases are classified into common test cases and device-specific test cases. You are advised to place common test cases in the **common** directory and device-specific test cases in the directories of the related devices.
64
65###  Writing Test Cases
66This test framework supports test cases written in multiple programming languages and provides different templates for different languages.
67
68#### C++ Test Case Example
69
70- Naming rules for source files
71
72    The source file name of test cases must be the same as that of the test suite. The file names must use lowercase letters and in the [Function]\_[Sub-function]\_**test** format. More specific sub-functions can be added as required.
73Example:
74    ```
75    calculator_sub_test.cpp
76    ```
77
78- Test case example
79    ```
80
81    #include "calculator.h"
82    #include <gtest/gtest.h>
83
84    using namespace testing::ext;
85
86    class CalculatorSubTest : public testing::Test {
87    public:
88        static void SetUpTestCase(void);
89        static void TearDownTestCase(void);
90        void SetUp();
91        void TearDown();
92    };
93
94    void CalculatorSubTest::SetUpTestCase(void)
95    {
96        // Set a setup function, which will be called before all test cases.
97    }
98
99    void CalculatorSubTest::TearDownTestCase(void)
100    {
101        // Set a teardown function, which will be called after all test cases.
102    }
103
104    void CalculatorSubTest::SetUp(void)
105    {
106        // Set a setup function, which will be called before each test case.
107    }
108
109    void CalculatorSubTest::TearDown(void)
110    {
111        // Set a teardown function, which will be called after each test case.
112    }
113
114    /**
115     * @tc.name: integer_sub_001
116     * @tc.desc: Verify the sub function.
117     * @tc.type: FUNC
118     * @tc.require: Issue Number
119     */
120    HWTEST_F(CalculatorSubTest, integer_sub_001, TestSize.Level1)
121    {
122        // Step 1 Call the function to obtain the result.
123        int actual = Sub(4, 0);
124
125        // Step 2 Use an assertion to compare the obtained result with the expected result.
126        EXPECT_EQ(4, actual);
127    }
128    ```
129    The procedure is as follows:
130    1. Add comment information to the test case file header.
131
132        Enter the header comment in the standard format. For details, see [Code Specifications](https://gitee.com/openharmony/docs/blob/master/en/contribute/code-contribution.md).
133
134    2. Add the test framework header file and namespace.
135
136        ```
137        #include <gtest/gtest.h>
138
139        using namespace testing::ext;
140        ```
141
142    3. Add the header file of the test class.
143
144       ```
145	   #include "calculator.h"
146       ```
147
148    4. Define the test suite (test class).
149        ```
150    	class CalculatorSubTest : public testing::Test {
151    	public:
152    	   static void SetUpTestCase(void);
153    	   static void TearDownTestCase(void);
154    	   void SetUp();
155    	   void TearDown();
156    	};
157
158    	void CalculatorSubTest::SetUpTestCase(void)
159    	{
160    	    // input testsuit setup step,setup invoked before all testcases
161    	}
162
163    	void CalculatorSubTest::TearDownTestCase(void)
164    	{
165    	    // input testsuit teardown step,teardown invoked after all testcases
166    	}
167
168    	void CalculatorSubTest::SetUp(void)
169    	{
170    	    // input testcase setup step,setup invoked before each testcases
171    	}
172
173        void CalculatorSubTest::TearDown(void)
174	    {
175	        // input testcase teardown step,teardown invoked after each testcases
176        }
177
178        ```
179
180       > **NOTE**
181       >
182       > When defining a test suite, ensure that the test suite name is the same as the target to build and uses the upper camel case style.
183
184    5. Add implementation of the test cases, including test case comments and logic.
185        ```
186    	/**
187    	 * @tc.name: integer_sub_001
188    	 * @tc.desc: Verify the sub function.
189    	 * @tc.type: FUNC
190    	 * @tc.require: Issue Number
191    	 */
192    	HWTEST_F(CalculatorSubTest, integer_sub_001, TestSize.Level1)
193		{
194		    // Step 1 Call the function to obtain the test result.
195		    int actual = Sub(4, 0);
196
197    	    // Step 2 Use an assertion to compare the obtained result with the expected result.
198        EXPECT_EQ(4, actual);
199    	}
200		```
201	    The following test case templates are provided for your reference.
202
203	    | Template        | Description                                                  |
204		| --------------- | ------------------------------------------------------------ |
205		| HWTEST(A,B,C)   | Use this template if the test case execution does not depend on setup or teardown. |
206		| HWTEST_F(A,B,C) | Use this template if the test case execution (excluding parameters) depends on setup and teardown. |
207	   | HWTEST_P(A,B,C) | Use this template if the test case execution (including parameters) depends on setup and teardown. |
208
209
210	    In the template names:
211
212	    - *A* indicates the test suite name.
213        - *B* indicates the test case name, which is in the *Function*\_*No.* format. The *No.* is a three-digit number starting from **001**.
214        - *C* indicates the test case level. There are five test case levels: guard-control level 0 and non-guard-control level 1 to level 4. Of levels 1 to 4, a smaller value indicates a more important function verified by the test case.
215
216    > **NOTE**
217    >
218    > - The expected result of each test case must have an assertion.
219    > - The test case level must be specified.
220    > - It is recommended that the test be implemented step by step according to the template.
221    > - The comment must contain the test case name, description, type, and requirement number, which are in the @tc.*xxx*: *value* format.The test case description must be in the @tc.xxx format. The test case type @tc.type can be any of the following:
222
223    | Test Case Type   | Code |
224    | ---------------- | ---- |
225    | Function test    | FUNC |
226    | Performance test | PERF |
227    | Reliability test | RELI |
228    | Security test    | SECU |
229    | Fuzz test        | FUZZ |
230
231#### JavaScript Test Case Example
232
233- Naming rules for source files
234
235    The source file name of a test case must be in the [Function]\[Sub-function]Test format, and each part must use the upper camel case style. More specific sub-functions can be added as required.
236
237    Example:
238
239    ```
240    AppInfoTest.js
241    ```
242
243- Test case example
244    ```
245    import app from '@system.app'
246
247    import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index'
248
249    describe("AppInfoTest", function () {
250        beforeAll(function() {
251            // Set a setup function, which will be called before all test cases.
252             console.info('beforeAll called')
253        })
254
255        afterAll(function() {
256             // Set a teardown function, which will be called after all test cases.
257             console.info('afterAll called')
258        })
259
260        beforeEach(function() {
261            // Set a setup function, which will be called before each test case.
262             console.info('beforeEach called')
263        })
264
265        afterEach(function() {
266            // Set a teardown function, which will be called after each test case.
267             console.info('afterEach called')
268        })
269
270        /*
271         * @tc.name:appInfoTest001
272         * @tc.desc:verify app info is not null
273         * @tc.type: FUNC
274         * @tc.require: Issue Number
275         */
276        it("appInfoTest001", 0, function () {
277            // Step 1 Call the function to obtain the test result.
278            var info = app.getInfo()
279
280            // Step 2 Use an assertion to compare the obtained result with the expected result.
281            expect(info != null).assertEqual(true)
282        })
283    })
284    ```
285    The procedure is as follows:
286    1. Add comment information to the test case file header.
287
288        Enter the header comment in the standard format. For details, see [Code Specifications](https://gitee.com/openharmony/docs/blob/master/en/contribute/code-contribution.md).
289
290    2. Import the APIs and JSUnit test library to test.
291	    ```
292    	import app from '@system.app'
293
294    	import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index'
295    	```
296    3. Define the test suite (test class).
297	    ```
298    	describe("AppInfoTest", function () {
299    	    beforeAll(function() {
300    	        // Set a setup function, which will be called before all test cases.
301    	         console.info('beforeAll called')
302    	    })
303
304    	    afterAll(function() {
305    	         // Set a teardown function, which will be called after all test cases.
306    	         console.info('afterAll called')
307    	    })
308
309    	    beforeEach(function() {
310    	        // Set a setup function, which will be called before each test case.
311    	         console.info('beforeEach called')
312    	    })
313
314    	    afterEach(function() {
315    	        // Set a teardown function, which will be called after each test case.
316    	         console.info('afterEach called')
317    	    })
318    	```
319    4. Add implementation of the test cases.
320	    ```
321    	/*
322    	 * @tc.name:appInfoTest001
323    	 * @tc.desc:verify app info is not null
324    	 * @tc.type: FUNC
325    	 * @tc.require: Issue Number
326    	 */
327    	 it("appInfoTest001", 0, function () {
328    	    // Step 1 Call the function to obtain the test result.
329            var info = app.getInfo()
330
331            // Step 2 Use an assertion to compare the obtained result with the expected result.
332            expect(info != null).assertEqual(true)
333    	 })
334    	```
335
336### Writing the Build File for Test Cases
337When a test case is executed, the test framework searches for the build file of the test case in the test case directory and builds the test case located. The following describes how to write build files (GN files) in different programming languages.
338
339#### Writing Build Files for Test Cases
340The following provides templates for different languages for your reference.
341
342- **Test case build file example (C++)**
343    ```c++
344
345    import("//build/test.gni")
346
347    module_output_path = "subsystem_examples/calculator"
348
349    config("module_private_config") {
350      visibility = [ ":*" ]
351
352      include_dirs = [ "../../../include" ]
353    }
354
355    ohos_unittest("CalculatorSubTest") {
356      module_out_path = module_output_path
357
358      sources = [
359        "../../../include/calculator.h",
360        "../../../src/calculator.cpp",
361      ]
362
363      sources += [ "calculator_sub_test.cpp" ]
364
365      configs = [ ":module_private_config" ]
366
367      deps = [ "//third_party/googletest:gtest_main" ]
368    }
369
370    group("unittest") {
371      testonly = true
372      deps = [":CalculatorSubTest"]
373    }
374    ```
375    The procedure is as follows:
376
377    1. Add comment information for the file header.
378
379        Enter the header comment in the standard format. For details, see [Code Specifications](https://gitee.com/openharmony/docs/blob/master/en/contribute/code-contribution.md).
380
381    2. Import the build template.
382
383    	```
384    	import("//build/test.gni")
385    	```
386
387    3. Specify the file output path.
388
389        ```
390       module_output_path = "subsystem_examples/calculator"
391       ```
392
393       > **NOTE**
394       >
395       > The output path is ***Part name*/*Module name***.
396
397
398
399    4. Configure the directories for dependencies.
400
401        ```
402        config("module_private_config") {
403            visibility = [ ":*" ]
404
405            include_dirs = [ "../../../include" ]
406          }
407        ```
408
409        > **NOTE**
410        >
411        > Generally, the dependency directories are configured here and directly referenced in the build script of the test case.
412
413    5. Set the output build file for the test cases.
414
415       ```
416       ohos_unittest("CalculatorSubTest") {
417         }
418       ```
419
420    6. Write the build script (add the source file, configuration, and dependencies) for the test cases.
421
422        ```
423        ohos_unittest("CalculatorSubTest") {
424             module_out_path = module_output_path
425             sources = [
426               "../../../include/calculator.h",
427               "../../../src/calculator.cpp",
428               "../../../test/calculator_sub_test.cpp"
429             ]
430             sources += [ "calculator_sub_test.cpp" ]
431             configs = [ ":module_private_config" ]
432             deps = [ "//third_party/googletest:gtest_main" ]
433           }
434        ```
435
436        > **NOTE**
437        >
438        > Set the test type based on actual requirements. The following test types are available:
439        >
440        > - **ohos_unittest**: unit test
441        > - **ohos_moduletest**: module test
442        > - **ohos_systemtest**: system test
443        > - **ohos_performancetest**: performance test
444        > - **ohos_securitytest**: security test
445        > - **ohos_reliabilitytest**: reliability test
446        > - **ohos_distributedtest**: distributed test
447
448    7. Group the test case files by test type.
449
450       ```
451       group("unittest") {
452         testonly = true
453         deps = [":CalculatorSubTest"]
454       }
455       ```
456
457       > **NOTE**
458       >
459       > Grouping test cases by test type allows you to execute a specific type of test cases when required.
460
461462
463- **Test case build file example (JavaScript)**
464
465    ```javascript
466
467    import("//build/test.gni")
468
469    module_output_path = "subsystem_examples/app_info"
470
471    ohos_js_unittest("GetAppInfoJsTest") {
472      module_out_path = module_output_path
473
474      hap_profile = "./config.json"
475      certificate_profile = "//test/developertest/signature/openharmony_sx.p7b"
476    }
477
478    group("unittest") {
479      testonly = true
480      deps = [ ":GetAppInfoJsTest" ]
481    }
482    ```
483
484    The procedure is as follows:
485
486    1. Add comment information for the file header.
487
488        Enter the header comment in the standard format. For details, see [Code Specifications](https://gitee.com/openharmony/docs/blob/master/en/contribute/code-contribution.md).
489
490    2. Import the build template.
491
492    	```
493    	import("//build/test.gni")
494    	```
495
496    3. Specify the file output path.
497
498    	```
499    	module_output_path = "subsystem_examples/app_info"
500    	```
501    	> **NOTE**
502    	>
503    	>  The output path is ***Part name*/*Module name***.
504
505    4. Set the output build file for the test cases.
506
507        ```
508        ohos_js_unittest("GetAppInfoJsTest") {
509          }
510        ```
511
512        > **NOTE**
513        >
514        > - Use the **ohos\_js\_unittest** template to define the JavaScript test suite. Pay attention to the difference between JavaScript and C++.
515        > - The file generated for the JavaScript test suite must be in .hap format and named after the test suite name defined here. The test suite name must end with **JsTest**.
516
517
518
519    5. Configure the **config.json** file and signature file, which are mandatory.
520
521    	```
522    	ohos_js_unittest("GetAppInfoJsTest") {
523    	  module_out_path = module_output_path
524
525    	  hap_profile = "./config.json"
526    	  certificate_profile = "//test/developertest/signature/openharmony_sx.p7b"
527    	}
528    	```
529    	**config.json** is the configuration file required for HAP build. You need to set **target** based on the tested SDK version. Default values can be retained for other items. The following is an example:
530
531    	```
532    	{
533    	  "app": {
534    	    "bundleName": "com.example.myapplication",
535    	    "vendor": "example",
536    	    "version": {
537    	      "code": 1,
538    	      "name": "1.0"
539    	    },
540    	    "apiVersion": {
541    	      "compatible": 4,
542    	      "target": 5 // Set it based on the tested SDK version. In this example, SDK5 is used.
543    	    }
544    	  },
545    	  "deviceConfig": {},
546    	  "module": {
547    	    "package": "com.example.myapplication",
548    	    "name": ".MyApplication",
549    	    "deviceType": [
550    	      "phone"
551    	    ],
552    	    "distro": {
553    	      "deliveryWithInstall": true,
554    	      "moduleName": "entry",
555    	      "moduleType": "entry"
556    	    },
557    	    "abilities": [
558    	      {
559    	      "skills": [
560    	          {
561    	            "entities": [
562    	              "entity.system.home"
563    	            ],
564    	            "actions": [
565    	              "action.system.home"
566    	            ]
567    	          }
568    	        ],
569    	        "name": "com.example.myapplication.MainAbility",
570    	        "icon": "$media:icon",
571    	        "description": "$string:mainability_description",
572    	        "label": "MyApplication",
573    	        "type": "page",
574    	        "launchType": "multiton"
575    	      }
576    	    ],
577    	    "js": [
578    	      {
579    	        "pages": [
580    	          "pages/index/index"
581    	        ],
582    	        "name": "default",
583    	          "window": {
584    	             "designWidth": 720,
585    	             "autoDesignWidth": false
586    	          }
587    	        }
588    	      ]
589    	    }
590    	  }
591    	```
592    6. Group the test case files by test type.
593    	```
594    	group("unittest") {
595    	  testonly = true
596    	  deps = [ ":GetAppInfoJsTest" ]
597    	}
598    	```
599    	> **NOTE**
600    	>
601    	> Grouping test cases by test type allows you to execute a specific type of test cases when required.
602
603#### Configuring ohos.build
604
605Configure the part build file to associate with specific test cases.
606```
607"partA": {
608    "module_list": [
609
610    ],
611    "inner_list": [
612
613    ],
614    "system_kits": [
615
616    ],
617    "test_list": [
618      "//system/subsystem/partA/calculator/test:unittest"  // Configure test under calculator.
619    ]
620 }
621```
622> **NOTE**
623>
624>  **test_list** contains the test cases of the corresponding module.
625
626### Configuring Test Case Resources
627Test case resources include external file resources, such as image files, video files, and third-party libraries, required for test case execution.
628
629Perform the following steps:
6301. Create the **resource** directory in the **test** directory of the part, and create a directory for the module in the **resource** directory to store resource files of the module.
631
6322. In the module directory under **resource**, create the **ohos_test.xml** file in the following format:
633	```
634	<?xml version="1.0" encoding="UTF-8"?>
635	<configuration ver="2.0">
636	    <target name="CalculatorSubTest">
637	        <preparer>
638	            <option name="push" value="test.jpg -> /data/test/resource" src="res"/>
639	            <option name="push" value="libc++.z.so -> /data/test/resource" src="out"/>
640	        </preparer>
641	    </target>
642	</configuration>
643	```
6443. In the build file of the test cases, configure **resource\_config\_file** to point to the resource file **ohos\_test.xml**.
645	```
646	ohos_unittest("CalculatorSubTest") {
647	  resource_config_file = "//system/subsystem/partA/test/resource/calculator/ohos_test.xml"
648	}
649	```
650	>**NOTE**
651	>
652	>- **target_name** indicates the test suite name defined in the **BUILD.gn** file in the **test** directory.
653	>- **preparer** indicates the action to perform before the test suite is executed.
654	>- **src="res"** indicates that the test resources are in the **resource** directory under the **test** directory.
655	>- **src="out"** indicates that the test resources are in the **out/release/$(*part*)** directory.
656
657## Executing Test Cases
658Before executing test cases, you need to modify the configuration based on the device used.
659
660### Modifying user_config.xml
661```
662<user_config>
663  <build>
664    <!-- Whether to build a demo case. The default value is false. If a demo case is required, change the value to true. -->
665    <example>false</example>
666    <!-- Whether to build the version. The default value is false. -->
667    <version>false</version>
668    <!-- Whether to build the test cases. The default value is true. If the build is already complete, change the value to false before executing the test cases.-->
669    <testcase>true</testcase>
670  </build>
671  <environment>
672    <!-- Configure the IP address and port number of the remote server to support connection to the device through the OpenHarmony Device Connector (HDC).-->
673    <device type="usb-hdc">
674      <ip></ip>
675      <port></port>
676      <sn></sn>
677    </device>
678    <!-- Configure the serial port information of the device to enable connection through the serial port.-->
679    <device type="com" label="ipcamera">
680      <serial>
681        <com></com>
682        <type>cmd</type>
683        <baud_rate>115200</baud_rate>
684        <data_bits>8</data_bits>
685        <stop_bits>1</stop_bits>
686        <timeout>1</timeout>
687      </serial>
688    </device>
689  </environment>
690  <!-- Configure the test case path. If the test cases have not been built (<testcase> is true), leave this parameter blank. If the build is complete, enter the path of the test cases.-->
691  <test_cases>
692    <dir></dir>
693  </test_cases>
694  <!-- Configure the coverage output path.-->
695  <coverage>
696    <outpath></outpath>
697  </coverage>
698  <!-- Configure the NFS mount information when the tested device supports only the serial port connection. Specify the NFS mapping path. host_dir indicates the NFS directory on the PC, and board_dir indicates the directory created on the board. -->
699  <NFS>
700    <host_dir></host_dir>
701    <mnt_cmd></mnt_cmd>
702    <board_dir></board_dir>
703  </NFS>
704</user_config>
705```
706>**NOTE**
707>
708>If HDC is connected to the device before the test cases are executed, you only need to configure the device IP address and port number, and retain the default settings for other parameters.
709
710### Executing Test Cases on Windows
711#### Building Test Cases
712
713Test cases cannot be built on Windows. You need to run the following command to build test cases on Linux:
714```
715./build.sh --product-name hispark_taurus_standard --build-target make_test
716```
717When the build is complete, the test cases are automatically saved in **out/hispark_taurus/packages/phone/images/tests**.
718
719>**NOTE**
720>
721>In the command, **hispark_taurus_standard** indicates the product supported by the current version, and **make_test** indicates all test cases. You can set the build options based on requirements:
722>
723>-  --**product-name**: specifies the name of the product to build. It is mandatory.
724>- --**build-target**: specifies the target to build. It is optional.
725
726#### Setting Up the Execution Environment
7271. On Windows, create the **Test** directory in the test framework and then create the **testcase** directory in the **Test** directory.
728
7292. Copy **developertest** and **xdevice** from the Linux environment to the **Test** directory on Windows, and copy the test cases to the **testcase** directory.
730
731	> **NOTE**
732	>
733	> Port the test framework and test cases from the Linux environment to the Windows environment for subsequent execution.
7343. Modify the **user_config.xml** file.
735	```
736	<build>
737	  <!-- Because the test cases have been built, change the value to false. -->
738	  <testcase>false</testcase>
739	</build>
740	<test_cases>
741	  <!-- The test cases are copied to the Windows environment. Change the test case output path to the path of the test cases in the Windows environment.-->
742	  <dir>D:\Test\testcase\tests</dir>
743	</test_cases>
744	```
745	>**NOTE**
746	>
747	>`<testcase>` indicates whether to build test cases. `<dir>` indicates the path for searching for test cases.
748
749#### Executing Test Cases
7501. Start the test framework.
751	```
752	start.bat
753	```
7542. Select the product.
755
756    After the test framework starts, you are asked to select a product. Select the development board to test, for example, **Hi3516DV300**.
757
7583. Execute test cases.
759
760    Run the following command to execute test cases:
761	```
762	run -t UT -ts CalculatorSubTest -tc integer_sub_00l
763	```
764	In the command:
765	```
766	-t [TESTTYPE]: specifies the test type, which can be UT, MST, ST, or PERF. This parameter is mandatory.
767	-tp [TESTPART]: specifies the part to test. This parameter can be used independently.
768	-tm [TESTMODULE]: specifies the module to test. This parameter must be used together with -tp.
769	-ts [TESTSUITE]: specifies a test suite. This parameter can be used independently.
770	-tc [TESTCASE]: specifies a test case. This parameter must be used together with -ts.
771	You can run h to display help information.
772	```
773### Executing Test Cases on Linux
774#### Mapping the Remote Port
775To enable test cases to be executed on a remote Linux server or a Linux VM, map the port to enable communication between the device and the remote server or VM. Configure port mapping as follows:
7761. On the HDC server, run the following commands:
777	```
778	hdc_std kill
779	hdc_std -m -s 0.0.0.0:8710
780	```
781	>**NOTE**
782	>
783	>The IP address and port number are default values.
7842. On the HDC client, run the following command:
785	```
786	hdc_std -s xx.xx.xx.xx:8710 list targets
787	```
788	>**NOTE**
789	>
790	>Enter the IP address of the device to test.
791
792#### Executing Test Cases
7931. Start the test framework.
794	```
795	./start.sh
796	```
7972. Select the product.
798
799    After the test framework starts, you are asked to select a product. Select the development board to test, for example, **Hi3516DV300**.
800
8013. Execute test cases.
802
803    The test framework locates the test cases based on the command, and automatically builds and executes the test cases.
804	```
805	run -t UT -ts CalculatorSubTest -tc interger_sub_00l
806	```
807	In the command:
808	```
809	-t [TESTTYPE]: specifies the test type, which can be UT, MST, ST, or PERF. This parameter is mandatory.
810	-tp [TESTPART]: specifies the part to test. This parameter can be used independently.
811	-tm [TESTMODULE]: specifies the module to test. This parameter must be used together with -tp.
812	-ts [TESTSUITE]: specifies a test suite. This parameter can be used independently.
813	-tc [TESTCASE]: specifies a test case. This parameter must be used together with -ts.
814	You can run -h to display help information.
815	```
816
817## Viewing the Test Report
818After the test cases are executed, the test result will be automatically generated. You can view the detailed test result in the related directory.
819
820### Test Result
821You can obtain the test result in the following directory:
822```
823test/developertest/reports/xxxx_xx_xx_xx_xx_xx
824```
825>**NOTE**
826>
827>The folder for test reports is automatically generated.
828
829The folder contains the following files:
830| Type| Description|
831| ------------ | ------------ |
832| result/ |Test cases in standard format|
833| log/plan_log_xxxx_xx_xx_xx_xx_xx.log | Test case logs|
834| summary_report.html | Test report summary|
835| details_report.html | Detailed test report|
836
837### Test Framework Logs
838```
839reports/platform_log_xxxx_xx_xx_xx_xx_xx.log
840```
841
842### Latest Test Report
843```
844reports/latest
845```
846
847## Repositories Involved
848
849[test\_xdevice](https://gitee.com/openharmony/test_xdevice/blob/master/README.md)
850