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