未验证 提交 cadd0fb4 编写于 作者: K king_he 提交者: Gitee

update en/device-dev/subsystems/subsys-testguide-test.md.

Signed-off-by: Nking_he <6384784@qq.com>
上级 836ffaac
......@@ -58,7 +58,8 @@ subsystem # Subsystem
...
```
> **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**<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.
### Writing Test Cases
This test framework supports test cases written in multiple programming languages and provides different templates for different languages.
......@@ -196,7 +197,8 @@ Example:
// Set a teardown function, which will be called after each test case.
}
```
> **Note**: 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.
> **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.
5. Add implementation of the test cases, including test case comments and logic.
```
......@@ -217,30 +219,30 @@ Example:
```
The following test case templates are provided for your reference.
| Type| Description|
| Type | Description |
| ------------| ------------|
| HWTEST(A,B,C)| Use this template if the test case execution does not depend on setup or teardown.|
| HWTEST_F(A,B,C)| Use this template if the test case execution (excluding parameters) depends on setup and teardown.|
| HWTEST_P(A,B,C)| Use this template if the test case execution (including parameters) depends on setup and teardown.|
| HWTEST(A,B,C) | Use this template if the test case execution does not depend on setup or teardown. |
| HWTEST_F(A,B,C) | Use this template if the test case execution (excluding parameters) depends on setup and teardown. |
| HWTEST_P(A,B,C) | Use this template if the test case execution (including parameters) depends on setup and teardown. |
In the template names:
- *A* indicates the test suite name.
- *B* indicates the test case name, which is in the *Function*\_*No.* format. The *No.* is a three-digit number starting from **001**.
- *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.
**Note**:
- The expected result of each test case must have an assertion.
- The test case level must be specified.
- 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, which are in the @tc.*xxx*: *value* format. The test case type @**tc.type** can be any of the following:
> **NOTE**
> - The expected result of each test case must have an assertion.
> - The test case level must be specified.
> 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, which are in the @tc.*xxx*: *value* format. The test case type @**tc.type** can be any of the following:
| Test Case Type|Code|
| Test Case Type | Code |
| ------------|------------|
|Function test|FUNC|
|Performance test|PERF|
|Reliability test|RELI|
|Security test|SECU|
|Fuzz test|FUZZ|
| Function test | FUNC |
| Performance test | PERF |
| Reliability test | RELI |
| Security test | SECU |
| Fuzz test | FUZZ |
**JavaScript Test Case Example**
......@@ -416,18 +418,24 @@ The following provides templates for different languages for your reference.
The procedure is as follows:
1. Add comment information for the file header.
```
```
# Copyright (c) 2021 XXXX Device Co., Ltd.
```
2. Import the build template.
```
```
import("//build/test.gni")
```
3. Specify the file output path.
```
```
module_output_path = "subsystem_examples/calculator"
```
> **Note**: The output path is ***Part name*/*Module name***.
> **NOTE**<br>
> The output path is ***Part name*/*Module name***.
4. Configure the directories for dependencies.
......@@ -438,7 +446,8 @@ The following provides templates for different languages for your reference.
include_dirs = [ "../../../include" ]
}
```
> **Note**: Generally, the dependency directories are configured here and directly referenced in the build script of the test case.
> **NOTE**<br>
> Generally, the dependency directories are configured here and directly referenced in the build script of the test case.
5. Set the output build file for the test cases.
......@@ -461,7 +470,8 @@ The following provides templates for different languages for your reference.
}
```
> **Note:** Set the test type based on actual requirements. The following test types are available:
> **NOTE**<br>
> Set the test type based on actual requirements. The following test types are available:
> - **ohos_unittest**: unit test
> - **ohos_moduletest**: module test
> - **ohos_systemtest**: system test
......@@ -478,7 +488,8 @@ The following provides templates for different languages for your reference.
deps = [":CalculatorSubTest"]
}
```
> **Note**: Grouping test cases by test type allows you to execute a specific type of test cases when required.
> **NOTE**<br>
> Grouping test cases by test type allows you to execute a specific type of test cases when required.
- **Test case build file example (JavaScript)**
......@@ -519,7 +530,8 @@ The following provides templates for different languages for your reference.
```
module_output_path = "subsystem_examples/app_info"
```
> **Note**: The output path is ***Part name*/*Module name***.
> **NOTE**<br>
> The output path is ***Part name*/*Module name***.
4. Set the output build file for the test cases.
......@@ -527,7 +539,7 @@ The following provides templates for different languages for your reference.
ohos_js_unittest("GetAppInfoJsTest") {
}
```
> **Note:**
> **NOTE**
>- Use the **ohos\_js\_unittest** template to define the JavaScript test suite. Pay attention to the difference between JavaScript and C++.
>- 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**.
......@@ -611,7 +623,8 @@ The following provides templates for different languages for your reference.
deps = [ ":GetAppInfoJsTest" ]
}
```
> **Note**: Grouping test cases by test type allows you to execute a specific type of test cases when required.
> **NOTE**<br>
> Grouping test cases by test type allows you to execute a specific type of test cases when required.
#### Configuring ohos.build
......@@ -632,7 +645,9 @@ Configure the part build file to associate with specific test cases.
]
}
```
> **Note**: **test_list** contains the test cases of the corresponding module.
> **NOTE**<br>
> **test_list** contains the test cases of the corresponding module.
### Configuring Test Case Resources
Test case resources include external file resources, such as image files, video files, and third-party libraries, required for test case execution.
......@@ -658,7 +673,7 @@ Perform the following steps:
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.**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="out"** indicates that the test resources are in the **out/release/$(*part*)** directory.
......@@ -711,7 +726,8 @@ Before executing test cases, you need to modify the configuration based on the d
</NFS>
</user_config>
```
>**Note**: 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.
> **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.
### Executing Test Cases on Windows
#### Building Test Cases
......@@ -720,7 +736,7 @@ Test cases cannot be built on Windows. You need to run the following command to
```
./build.sh --product-name hispark_taurus_standard --build-target make_test
```
>Note:
> **NOTE**<br>
>- **product-name**: specifies the name of the product to build, for example, **hispark_taurus_standard**.
>- **build-target**: specifies the test case to build. **make_test** indicates all test cases. You can specify the test cases based on requirements.
......@@ -731,7 +747,8 @@ After the build is complete, the test cases are automatically saved in **out/his
2. Copy **developertest** and **xdevice** from the Linux environment to the **Test** directory on Windows, and copy the test cases to the **testcase** directory.
>**Note**: Port the test framework and test cases from the Linux environment to the Windows environment for subsequent execution.
> **NOTE**<br>
> Port the test framework and test cases from the Linux environment to the Windows environment for subsequent execution.
3. Modify the **user_config.xml** file.
```
......@@ -744,7 +761,8 @@ After the build is complete, the test cases are automatically saved in **out/his
<dir>D:\Test\testcase\tests</dir>
</test_cases>
```
>**Note**: `<testcase>` indicates whether to build test cases. `<dir>` indicates the path for searching for test cases.
> **NOTE**<br>
> `<testcase>` indicates whether to build test cases. `<dir>` indicates the path for searching for test cases.
#### Executing Test Cases
1. Start the test framework.
......@@ -778,13 +796,15 @@ To enable test cases to be executed on a remote Linux server or a Linux VM, map
hdc_std kill
hdc_std -m -s 0.0.0.0:8710
```
>**Note**: The IP address and port number are default values.
> **NOTE**<br>
> The IP address and port number are default values.
2. On the HDC client, run the following command:
```
hdc_std -s xx.xx.xx.xx:8710 list targets
```
>**Note**: Enter the IP address of the device to test.
> **NOTE**<br>
> Enter the IP address of the device to test.
#### Executing Test Cases
1. Start the test framework.
......@@ -819,15 +839,16 @@ You can obtain the test result in the following directory:
```
test/developertest/reports/xxxx_xx_xx_xx_xx_xx
```
>**Note**: The folder for test reports is automatically generated.
> **NOTE**<br>
> The folder for test reports is automatically generated.
The folder contains the following files:
| Type| Description|
| Type | Description |
| ------------ | ------------ |
| result/ |Test cases in standard format|
| log/plan_log_xxxx_xx_xx_xx_xx_xx.log | Test case logs|
| summary_report.html | Test report summary|
| details_report.html | Detailed test report|
| result/ | Test cases in standard format. |
| log/plan_log_xxxx_xx_xx_xx_xx_xx.log | Test case logs. |
| summary_report.html | Test report summary. |
| details_report.html | Detailed test report. |
### Test Framework Logs
```
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册