提交 085551a9 编写于 作者: O openharmony_ci 提交者: Gitee

!870 更新 test_subsystem.md 英文

Merge pull request !870 from Annie_wang/master
...@@ -4,7 +4,7 @@ OpenHarmony provides a comprehensive auto-test framework for designing test case ...@@ -4,7 +4,7 @@ OpenHarmony provides a comprehensive auto-test framework for designing test case
This document describes how to use the OpenHarmony test framework. This document describes how to use the OpenHarmony test framework.
## Setting Up the Environment ## Setting Up the Environment
The test framework depends on the Python running environment. Before using the test framework, set up the environment as follows: The test framework depends on the Python running environment. Before using the test framework, set up the environment as follows:
- [Setting Up the Environment](../device-dev/subsystems/subsys-testguide-test.md#section175012297491) - [Setting Up the Environment](../device-dev/subsystems/subsys-testguide-envbuild.md)
- [Obtaining Source Code](../device-dev/get-code/sourcecode-acquire.md) - [Obtaining Source Code](../device-dev/get-code/sourcecode-acquire.md)
...@@ -39,21 +39,23 @@ subsystem # Subsystem ...@@ -39,21 +39,23 @@ subsystem # Subsystem
│ │ ├── unittest # Unit test │ │ ├── unittest # Unit test
│ │ │ ├── common # Common test cases │ │ │ ├── common # Common test cases
│ │ │ │ ├── BUILD.gn # Build file of test cases │ │ │ │ ├── BUILD.gn # Build file of test cases
│ │ │ │ ── testA_test.cpp # Source code of unit test cases │ │ │ │ ── testA_test.cpp # Source code of unit test cases
│ │ │ ├── phone # Test cases for mobile phones │ │ │ ├── phone # Test cases for mobile phones
│ │ │ ├── ivi # Test cases for head units │ │ │ ├── ivi # Test cases for head units
│ │ │ └── liteos-a # Test cases for the IP cameras that use the LiteOS kernel │ │ │ └── liteos-a # Test cases for the IP cameras that use the LiteOS kernel
│ │ └── resource # Dependency resources │ │ ├── moduletest # Module test
│ │ └── ohos_test.xml │ │ ...
│ │
│ ├── moduleB # Module B │ ├── moduleB # Module B
│ ├── test │ ├── test
│ │ └── moduletest # Module test │ │ └── resource # Dependency resources
│ │ ├── common │ │ ├── moduleA # Module A
│ │ ├── phone │ │ │ ├── ohos_test.xml # Resource configuration file
│ │ ├── ivi │ │ ... └── 1.txt # Resource
│ │ └── liteos-a │ │
│ │ ... │ ├── ohos_build # Build entry configuration
│ └── ohos_build # Build entry configuration │ ...
... ...
``` ```
> **Note:** 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. > **Note:** 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.
...@@ -230,11 +232,15 @@ Example: ...@@ -230,11 +232,15 @@ Example:
- The expected result of each test case must have an assertion. - The expected result of each test case must have an assertion.
- The test case level must be specified. - The test case level must be specified.
- It is recommended that the test be implemented step by step according to the template. - It is recommended that the test be implemented step by step according to the template.
- The comment must contain the test case name, description, type, and requirement number. The test case description must be in the @tc.xxx format. The test case type @tc.type can be any of the following: - 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:
| Test Case Type|Function test|Performance test|Reliability test|Security test|Fuzz test| | Test Case Type|Code|
| ------------|------------|------------|------------|------------|------------| | ------------|------------|
| Code|FUNC|PERF|RELI|SECU|FUZZ| |Function test |FUNC|
|Performance test |PERF|
|Reliability test |RELI|
|Security test |SECU|
|Fuzz test |FUZZ|
**JavaScript Test Case Example** **JavaScript Test Case Example**
...@@ -632,9 +638,9 @@ Configure the part build file to associate with specific test cases. ...@@ -632,9 +638,9 @@ Configure the part build file to associate with specific test cases.
Test case resources include external file resources, such as image files, video files, and third-party libraries, required for test case execution. Test case resources include external file resources, such as image files, video files, and third-party libraries, required for test case execution.
Perform the following steps: Perform the following steps:
1. Under the **test** directory of a part or module, create the **resource** directory to store resource files. 1. 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.
2. In the **resource** directory, create the **ohos_test.xml** file in the following format: 2. In the module directory under **resource**, create the **ohos_test.xml** file in the following format:
``` ```
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<configuration ver="2.0"> <configuration ver="2.0">
...@@ -649,14 +655,14 @@ Perform the following steps: ...@@ -649,14 +655,14 @@ Perform the following steps:
3. In the build file of the test cases, configure **resource\_config\_file** to point to the resource file **ohos\_test.xml**. 3. In the build file of the test cases, configure **resource\_config\_file** to point to the resource file **ohos\_test.xml**.
``` ```
ohos_unittest("CalculatorSubTest") { ohos_unittest("CalculatorSubTest") {
resource_config_file = "//system/subsystem/partA/calculator/test/resource/ohos_test.xml" resource_config_file = "//system/subsystem/partA/test/resource/calculator/ohos_test.xml"
} }
``` ```
>**Note:** >**Note:**
>- **target_name** indicates the test suite name defined in the **BUILD.gn** file in the **test** directory. >- **target_name** indicates the test suite name defined in the **BUILD.gn** file in the **test** directory.
>- **preparer** indicates the action to perform before the test suite is executed. >- **preparer** indicates the action to perform before the test suite is executed.
>- **src="res"** indicates that the test resources are in the **resource** directory under the **test** directory. >- **src="res"** indicates that the test resources are in the **resource** directory under the **test** directory.
>- **src="out"** indicates that the test resources are in the **out/release/$(component)** directory. >- **src="out"** indicates that the test resources are in the **out/release/$(part)** directory.
## Executing Test Cases ## Executing Test Cases
Before executing test cases, you need to modify the configuration based on the device used. Before executing test cases, you need to modify the configuration based on the device used.
...@@ -730,7 +736,7 @@ When the build is complete, the test cases are automatically saved in the **out/ ...@@ -730,7 +736,7 @@ When the build is complete, the test cases are automatically saved in the **out/
3. Modify the **user_config.xml** file. 3. Modify the **user_config.xml** file.
``` ```
<build> <build>
<!-- Because the test cases have been built, change the value to false -->. <!-- Because the test cases have been built, change the value to false. -->
<testcase>false</testcase> <testcase>false</testcase>
</build> </build>
<test_cases> <test_cases>
...@@ -757,16 +763,16 @@ When the build is complete, the test cases are automatically saved in the **out/ ...@@ -757,16 +763,16 @@ When the build is complete, the test cases are automatically saved in the **out/
``` ```
In the command: In the command:
``` ```
-t [TESTTYPE]: specifies the test case type, which can be UT, MST, ST, or PERF. This parameter is mandatory. -t [TESTTYPE]: specifies the test type, which can be UT, MST, ST, or PERF. This parameter is mandatory.
-tp [TESTTYPE]: specifies a part, which can be used independently. -tp [TESTPART]: specifies the part to test. This parameter can be used independently.
-tm [TESTTYPE]: specifies a module. This parameter must be specified together with -tp. -tm [TESTMODULE]: specifies the module to test. This parameter must be used together with -tp.
-ts [TESTTYPE]: specifies a test suite, which can be used independently. -ts [TESTSUITE]: specifies the test suite. This parameter can be used independently.
-tc [TESTTYPE]: specifies a test case. This parameter must be specified together with -ts. -tc [TESTCASE]: specifies the test case. This parameter must be used together with -ts.
You can run -h to display help information. You can run -h to display help information.
``` ```
### Executing Test Cases on Linux ### Executing Test Cases on Linux
#### Mapping Remote Port #### Mapping Remote Port
To 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 remove server or VM. Configure port mapping as follows: To 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:
1. On the HDC server, run the following commands: 1. On the HDC server, run the following commands:
``` ```
hdc_std kill hdc_std kill
...@@ -797,11 +803,11 @@ To enable test cases to be executed on a remote Linux server or a Linux VM, map ...@@ -797,11 +803,11 @@ To enable test cases to be executed on a remote Linux server or a Linux VM, map
``` ```
In the command: In the command:
``` ```
-t [TESTTYPE]: specifies the test case type, which can be UT, MST, ST, or PERF. This parameter is mandatory. -t [TESTTYPE]: specifies the test type, which can be UT, MST, ST, or PERF. This parameter is mandatory.
-tp [TESTTYPE]: specifies a part, which can be used independently. -tp [TESTPART]: specifies the part to test. This parameter can be used independently.
-tm [TESTTYPE]: specifies a module. This parameter must be specified together with -tp. -tm [TESTMODULE]: specifies the module to test. This parameter must be used together with -tp.
-ts [TESTTYPE]: specifies a test suite, which can be used independently. -ts [TESTSUITE]: specifies the test suite. This parameter can be used independently.
-tc [TESTTYPE]: specifies a test case. This parameter must be specified together with -ts. -tc [TESTCASE]: specifies the test case. This parameter must be used together with -ts.
You can run -h to display help information. You can run -h to display help information.
``` ```
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册