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