• Home
Name Date Size #Lines LOC

..--

.history/ability/ability_runtime/actsstartupruleoptimizetest/entry/src/main/ets/test/07-Sep-2024-214202

ability/07-Sep-2024-289,877252,159

ability_lite/07-Sep-2024-2,4031,841

account/07-Sep-2024-43,80535,727

advertising/07-Sep-2024-2,2971,868

ai/07-Sep-2024-79,61357,233

ai_lite/07-Sep-2024-2,6481,537

appexecfwk_lite/07-Sep-2024-1,4941,095

applications/07-Sep-2024-5,5224,818

arkcompiler/07-Sep-2024-9,3687,817

arkui/07-Sep-2024-2,200,9381,953,865

barrierfree/07-Sep-2024-17,60912,601

build/07-Sep-2024-3127

build_lite/07-Sep-2024-168155

bundlemanager/07-Sep-2024-70,87062,405

commonlibrary/07-Sep-2024-202,375160,556

commonlibrary_lite/file_hal/07-Sep-2024-1,263828

communication/07-Sep-2024-65,09049,864

communication_lite/07-Sep-2024-4,4083,390

customization/07-Sep-2024-8,6928,117

demo/07-Sep-2024-2,6831,829

developtools/07-Sep-2024-327270

distributed_schedule_lite/07-Sep-2024-15,03110,982

distributeddatamgr/07-Sep-2024-193,626166,249

distributeddatamgr_lite/07-Sep-2024-2,6811,893

figures/07-Sep-2024-

global/07-Sep-2024-24,25318,047

global_lite/i18n_lite/07-Sep-2024-9,7916,806

graphic/07-Sep-2024-934,460695,591

hdf/07-Sep-2024-5,6424,741

hiviewdfx/07-Sep-2024-29,65022,983

hiviewdfx_lite/07-Sep-2024-584313

inputmethod/07-Sep-2024-28,23926,006

iothardware_lite/peripheral_hal/07-Sep-2024-903392

kernel_lite/07-Sep-2024-44,58230,316

location/07-Sep-2024-8,2976,346

msdp/07-Sep-2024-729546

multimedia/07-Sep-2024-429,037361,558

multimedia_lite/07-Sep-2024-8,3756,397

multimodalinput/07-Sep-2024-9,7947,360

notification/07-Sep-2024-33,50427,853

open_posix_testsuite/07-Sep-2024-780729

ostest/07-Sep-2024-490404

powermgr/07-Sep-2024-13,55910,646

request/07-Sep-2024-18,85517,728

resourceschedule/07-Sep-2024-19,11414,885

sample_lite/07-Sep-2024-438251

security/07-Sep-2024-168,512149,785

security_lite/07-Sep-2024-13,5759,915

sensors/07-Sep-2024-52,98539,253

sensors_lite/07-Sep-2024-333228

startup/07-Sep-2024-5,6114,057

startup_lite/07-Sep-2024-3,5892,358

storage/07-Sep-2024-82,11155,162

telephony/07-Sep-2024-171,369159,808

testfwk/07-Sep-2024-3,0572,850

testtools/07-Sep-2024-10081

theme/07-Sep-2024-2,9042,703

time/07-Sep-2024-4,5184,120

update_lite/07-Sep-2024-464288

usb/07-Sep-2024-5,2704,002

useriam/07-Sep-2024-4,5383,285

validator/07-Sep-2024-38,30735,392

xts/07-Sep-2024-640530

xts_lite/device_attest_lite/07-Sep-2024-509373

.gitattributesD07-Sep-20241.4 KiB2221

7445.patchD07-Sep-2024173.1 KiB4,8144,713

BUILD.gnD07-Sep-2024980 3328

LICENSED07-Sep-202410.1 KiB177150

OAT.xmlD07-Sep-20248.2 KiB11259

README.mdD07-Sep-202440 KiB649525

README_zh.mdD07-Sep-202449.2 KiB1,015810

build.shD07-Sep-20245.1 KiB142115

bundle.jsonD07-Sep-20241 KiB4444

ci_build.shD07-Sep-20243.2 KiB10177

get_dependency.pyD07-Sep-20245.6 KiB152100

runtest.shD07-Sep-20245.9 KiB188155

test_packages.gniD07-Sep-20244.4 KiB123109

xts_acts_config.gniD07-Sep-2024624 1513

README.md

1# XTS<a name="EN-US_TOPIC_0000001126156429"></a>
2
3-   [Introduction](#section465982318513)
4-   [System Types](#section125090457443)
5-   [Directory Structure](#section161941989596)
6-   [Constraints](#section119744591305)
7-   [Usage Guidelines](#section137768191623)
8-   [Test Case Development Guidelines](#section3695134065513)
9    -   [C-based Test Case Development and Compilation \(for the Mini System\)](#section198193336544)
10    -   [C-based Test Case Execution \(for the Mini System\)](#section13820233175418)
11    -   [C++-based Test Case Development and Compilation \(for Standard and Small Systems\)](#section3822123311540)
12    -   [C++-based Test Case Execution \(for Standard and Small Systems\)](#section128222336544)
13    -   [JavaScript-based Test Case Development \(for the Standard System\)](#section159801435165220)
14    -   [JavaScript-based Test Case Packaging \(for the Standard System\)](#section445519106559)
15
16
17## Introduction<a name="section465982318513"></a>
18
19The X test suite \(XTS\) subsystem contains a set of OpenHarmony certification test suites, including the currently supported application compatibility test suite \(ACTS\) and the device compatibility test suite \(DCTS\) that will be supported in the future.
20
21This subsystem contains the ACTS and  **tools**  software package.
22
23-   The  **acts**  directory stores the source code and configuration files of ACTS test cases. The ACTS helps device vendors detect the software incompatibility as early as possible and ensures that the software is compatible to OpenHarmony during the entire development process.
24-   The  **tools**  software package stores the test case development framework related to  **acts**.
25
26## System Types<a name="section125090457443"></a>
27
28OpenHarmony supports the following system types:
29
30-   Mini system
31
32    A mini system runs on the devices whose memory is greater than or equal to 128 KiB and that are equipped with MCU processors such as ARM Cortex-M and 32-bit RISC-V. This system provides multiple lightweight network protocols and graphics frameworks, and a wide range of read/write components for the IoT bus. Typical products include connection modules, sensors, and wearables for smart home.
33
34-   Small system
35
36    A small system runs on the devices whose memory is greater than or equal to 1 MiB and that are equipped with application processors such as ARM Cortex-A. This system provides higher security capabilities, standard graphics frameworks, and video encoding and decoding capabilities. Typical products include smart home IP cameras, electronic cat eyes, and routers, and event data recorders \(EDRs\) for smart travel.
37
38-   Standard system
39
40    A standard system runs on the devices whose memory is greater than or equal to 128 MiB and that are equipped with application processors such as ARM Cortex-A. This system provides a complete application framework supporting the enhanced interaction, 3D GPU, hardware composer, diverse components, and rich animations. This system applies to high-end refrigerator displays.
41
42
43## Directory Structure<a name="section161941989596"></a>
44
45```
46/test/xts
47├── acts                # Test code
48│   └── subsystem       # Source code of subsystem test cases for the standard system
49│   └── subsystem_lite  # Source code of subsystems test cases for mini and small systems
50│   └── BUILD.gn        # Build configuration of test cases for the standard system
51│   └── build_lite
52│       └── BUILD.gn    # Build configuration of test cases for mini and small systems
53└── tools               # Test tool code
54```
55
56## Constraints<a name="section119744591305"></a>
57
58Test cases for the mini system must be developed based on C, and those for the small system must be developed based on C++.
59
60## Usage Guidelines<a name="section137768191623"></a>
61
62**Table  1**  Test case levels
63
64<a name="table12856113719456"></a>
65<table><thead align="left"><tr id="row88561737114517"><th class="cellrowborder" valign="top" width="33.333333333333336%" id="mcps1.2.4.1.1"><p id="p54711456452"><a name="p54711456452"></a><a name="p54711456452"></a>Level</p>
66</th>
67<th class="cellrowborder" valign="top" width="33.283328332833285%" id="mcps1.2.4.1.2"><p id="p114834544518"><a name="p114834544518"></a><a name="p114834544518"></a>Definition</p>
68</th>
69<th class="cellrowborder" valign="top" width="33.383338333833386%" id="mcps1.2.4.1.3"><p id="p348154574518"><a name="p348154574518"></a><a name="p348154574518"></a>Scope</p>
70</th>
71</tr>
72</thead>
73<tbody><tr id="row78561137134514"><td class="cellrowborder" valign="top" width="33.333333333333336%" headers="mcps1.2.4.1.1 "><p id="p17481345124512"><a name="p17481345124512"></a><a name="p17481345124512"></a>Level0</p>
74</td>
75<td class="cellrowborder" valign="top" width="33.283328332833285%" headers="mcps1.2.4.1.2 "><p id="p1548945204514"><a name="p1548945204514"></a><a name="p1548945204514"></a>Smoke</p>
76</td>
77<td class="cellrowborder" valign="top" width="33.383338333833386%" headers="mcps1.2.4.1.3 "><p id="p174824517456"><a name="p174824517456"></a><a name="p174824517456"></a>Verifies basic functionalities of key features and basic DFX attributes with the most common input. The pass result indicates that the features are runnable.</p>
78</td>
79</tr>
80<tr id="row28563372451"><td class="cellrowborder" valign="top" width="33.333333333333336%" headers="mcps1.2.4.1.1 "><p id="p448445144512"><a name="p448445144512"></a><a name="p448445144512"></a>Level1</p>
81</td>
82<td class="cellrowborder" valign="top" width="33.283328332833285%" headers="mcps1.2.4.1.2 "><p id="p44813452452"><a name="p44813452452"></a><a name="p44813452452"></a>Basic</p>
83</td>
84<td class="cellrowborder" valign="top" width="33.383338333833386%" headers="mcps1.2.4.1.3 "><p id="p648184584514"><a name="p648184584514"></a><a name="p648184584514"></a>Verifies basic functionalities of key features and basic DFX attributes with common input. The pass result indicates that the features are testable.</p>
85</td>
86</tr>
87<tr id="row12856137204514"><td class="cellrowborder" valign="top" width="33.333333333333336%" headers="mcps1.2.4.1.1 "><p id="p164834520453"><a name="p164834520453"></a><a name="p164834520453"></a>Level2</p>
88</td>
89<td class="cellrowborder" valign="top" width="33.283328332833285%" headers="mcps1.2.4.1.2 "><p id="p148245184511"><a name="p148245184511"></a><a name="p148245184511"></a>Major</p>
90</td>
91<td class="cellrowborder" valign="top" width="33.383338333833386%" headers="mcps1.2.4.1.3 "><p id="p348945124510"><a name="p348945124510"></a><a name="p348945124510"></a>Verifies basic functionalities of key features and basic DFX attributes with common input and errors. The pass result indicates that the features are functional and ready for beta testing.</p>
92</td>
93</tr>
94<tr id="row48571137204514"><td class="cellrowborder" valign="top" width="33.333333333333336%" headers="mcps1.2.4.1.1 "><p id="p7481545184513"><a name="p7481545184513"></a><a name="p7481545184513"></a>Level3</p>
95</td>
96<td class="cellrowborder" valign="top" width="33.283328332833285%" headers="mcps1.2.4.1.2 "><p id="p1748184514455"><a name="p1748184514455"></a><a name="p1748184514455"></a>Regular</p>
97</td>
98<td class="cellrowborder" valign="top" width="33.383338333833386%" headers="mcps1.2.4.1.3 "><p id="p8481245104519"><a name="p8481245104519"></a><a name="p8481245104519"></a>Verifies functionalities of all key features, and all DFX attributes with common and uncommon input combinations or normal and abnormal preset conditions.</p>
99</td>
100</tr>
101<tr id="row14857133712451"><td class="cellrowborder" valign="top" width="33.333333333333336%" headers="mcps1.2.4.1.1 "><p id="p1248144515456"><a name="p1248144515456"></a><a name="p1248144515456"></a>Level4</p>
102</td>
103<td class="cellrowborder" valign="top" width="33.283328332833285%" headers="mcps1.2.4.1.2 "><p id="p94804514519"><a name="p94804514519"></a><a name="p94804514519"></a>Rare</p>
104</td>
105<td class="cellrowborder" valign="top" width="33.383338333833386%" headers="mcps1.2.4.1.3 "><p id="p1248445164516"><a name="p1248445164516"></a><a name="p1248445164516"></a>Verifies functionalities of key features under extremely abnormal presets and uncommon input combinations.</p>
106</td>
107</tr>
108</tbody>
109</table>
110
111**Table  2**  Test case granularities
112
113<a name="table1690733521014"></a>
114<table><thead align="left"><tr id="row9907143516105"><th class="cellrowborder" valign="top" width="19.591959195919593%" id="mcps1.2.4.1.1"><p id="p1141312416102"><a name="p1141312416102"></a><a name="p1141312416102"></a>Test Scale</p>
115</th>
116<th class="cellrowborder" valign="top" width="35.17351735173517%" id="mcps1.2.4.1.2"><p id="p34131416109"><a name="p34131416109"></a><a name="p34131416109"></a>Test Objects</p>
117</th>
118<th class="cellrowborder" valign="top" width="45.23452345234523%" id="mcps1.2.4.1.3"><p id="p12413141171010"><a name="p12413141171010"></a><a name="p12413141171010"></a>Test Environment</p>
119</th>
120</tr>
121</thead>
122<tbody><tr id="row2907335181017"><td class="cellrowborder" valign="top" width="19.591959195919593%" headers="mcps1.2.4.1.1 "><p id="p6414134117109"><a name="p6414134117109"></a><a name="p6414134117109"></a>LargeTest</p>
123</td>
124<td class="cellrowborder" valign="top" width="35.17351735173517%" headers="mcps1.2.4.1.2 "><p id="p20414104113101"><a name="p20414104113101"></a><a name="p20414104113101"></a>Service functionalities, all-scenario features, and mechanical power environment (MPE) and scenario-level DFX</p>
125</td>
126<td class="cellrowborder" valign="top" width="45.23452345234523%" headers="mcps1.2.4.1.3 "><p id="p5414841121013"><a name="p5414841121013"></a><a name="p5414841121013"></a>Devices close to real devices</p>
127</td>
128</tr>
129<tr id="row10907635131015"><td class="cellrowborder" valign="top" width="19.591959195919593%" headers="mcps1.2.4.1.1 "><p id="p19414134117104"><a name="p19414134117104"></a><a name="p19414134117104"></a>MediumTest</p>
130</td>
131<td class="cellrowborder" valign="top" width="35.17351735173517%" headers="mcps1.2.4.1.2 "><p id="p114141241141018"><a name="p114141241141018"></a><a name="p114141241141018"></a>Modules, subsystem functionalities after module integration, and DFX</p>
132</td>
133<td class="cellrowborder" valign="top" width="45.23452345234523%" headers="mcps1.2.4.1.3 "><p id="p14414941111015"><a name="p14414941111015"></a><a name="p14414941111015"></a>Single device that is actually used. You can perform message simulation, but do not mock functions.</p>
134</td>
135</tr>
136<tr id="row1990713353100"><td class="cellrowborder" valign="top" width="19.591959195919593%" headers="mcps1.2.4.1.1 "><p id="p641414110109"><a name="p641414110109"></a><a name="p641414110109"></a>SmallTest</p>
137</td>
138<td class="cellrowborder" valign="top" width="35.17351735173517%" headers="mcps1.2.4.1.2 "><p id="p54141541181018"><a name="p54141541181018"></a><a name="p54141541181018"></a>Modules, classes, and functions</p>
139</td>
140<td class="cellrowborder" valign="top" width="45.23452345234523%" headers="mcps1.2.4.1.3 "><p id="p1841494131013"><a name="p1841494131013"></a><a name="p1841494131013"></a>Local PC. Use a large number of mocks to replace dependencies with other modules.</p>
141</td>
142</tr>
143</tbody>
144</table>
145
146**Table  3**  Test types
147
148<a name="table18811230124619"></a>
149<table><thead align="left"><tr id="row48163019466"><th class="cellrowborder" valign="top" width="19.040000000000003%" id="mcps1.2.3.1.1"><p id="p1791784418465"><a name="p1791784418465"></a><a name="p1791784418465"></a>Type</p>
150</th>
151<th class="cellrowborder" valign="top" width="80.96%" id="mcps1.2.3.1.2"><p id="p2917164444614"><a name="p2917164444614"></a><a name="p2917164444614"></a>Definition</p>
152</th>
153</tr>
154</thead>
155<tbody><tr id="row682630104615"><td class="cellrowborder" valign="top" width="19.040000000000003%" headers="mcps1.2.3.1.1 "><p id="p1091784414469"><a name="p1091784414469"></a><a name="p1091784414469"></a>Function</p>
156</td>
157<td class="cellrowborder" valign="top" width="80.96%" headers="mcps1.2.3.1.2 "><p id="p16917344104618"><a name="p16917344104618"></a><a name="p16917344104618"></a>Tests the correctness of both service and platform functionalities provided by the tested object for end users or developers.</p>
158</td>
159</tr>
160<tr id="row1821930154611"><td class="cellrowborder" valign="top" width="19.040000000000003%" headers="mcps1.2.3.1.1 "><p id="p591714474612"><a name="p591714474612"></a><a name="p591714474612"></a>Performance</p>
161</td>
162<td class="cellrowborder" valign="top" width="80.96%" headers="mcps1.2.3.1.2 "><p id="p15917154410463"><a name="p15917154410463"></a><a name="p15917154410463"></a>Tests the processing capability of the tested object under specific preset conditions and load models. The processing capability is measured by the service volume that can be processed in a unit time, for example, call per second, frame per second, or event processing volume per second.</p>
163</td>
164</tr>
165<tr id="row13821030104616"><td class="cellrowborder" valign="top" width="19.040000000000003%" headers="mcps1.2.3.1.1 "><p id="p691711440467"><a name="p691711440467"></a><a name="p691711440467"></a>Power</p>
166</td>
167<td class="cellrowborder" valign="top" width="80.96%" headers="mcps1.2.3.1.2 "><p id="p159171544104616"><a name="p159171544104616"></a><a name="p159171544104616"></a>Tests the power consumption of the tested object in a certain period of time under specific preset conditions and load models.</p>
168</td>
169</tr>
170<tr id="row6821330114618"><td class="cellrowborder" valign="top" width="19.040000000000003%" headers="mcps1.2.3.1.1 "><p id="p13917164454612"><a name="p13917164454612"></a><a name="p13917164454612"></a>Reliability</p>
171</td>
172<td class="cellrowborder" valign="top" width="80.96%" headers="mcps1.2.3.1.2 "><p id="p11917194416465"><a name="p11917194416465"></a><a name="p11917194416465"></a>Tests the service performance of the tested object under common and uncommon input conditions, or specified service volume pressure and long-term continuous running pressure. The test covers stability, pressure handling, fault injection, and Monkey test times.</p>
173</td>
174</tr>
175<tr id="row11821930184612"><td class="cellrowborder" valign="top" width="19.040000000000003%" headers="mcps1.2.3.1.1 "><p id="p1691774474618"><a name="p1691774474618"></a><a name="p1691774474618"></a>Security</p>
176</td>
177<td class="cellrowborder" valign="top" width="80.96%" headers="mcps1.2.3.1.2 "><a name="ul112421652121513"></a><a name="ul112421652121513"></a><ul id="ul112421652121513"><li>Tests the capability of defending against security threats, including but not limited to unauthorized access, use, disclosure, damage, modification, and destruction, to ensure information confidentiality, integrity, and availability.</li><li>Tests the privacy protection capability to ensure that the collection, use, retention, disclosure, and disposal of users' private data comply with laws and regulations.</li><li>Tests the compliance with various security specifications, such as security design, security requirements, and security certification of the Ministry of Industry and Information Technology (MIIT).</li></ul>
178</td>
179</tr>
180<tr id="row16825307467"><td class="cellrowborder" valign="top" width="19.040000000000003%" headers="mcps1.2.3.1.1 "><p id="p129188444462"><a name="p129188444462"></a><a name="p129188444462"></a>Global</p>
181</td>
182<td class="cellrowborder" valign="top" width="80.96%" headers="mcps1.2.3.1.2 "><p id="p179186444465"><a name="p179186444465"></a><a name="p179186444465"></a>Tests the internationalized data and localization capabilities of the tested object, including multi-language display, various input/output habits, time formats, and regional features, such as currency, time, and culture taboos.</p>
183</td>
184</tr>
185<tr id="row08211308464"><td class="cellrowborder" valign="top" width="19.040000000000003%" headers="mcps1.2.3.1.1 "><p id="p191814447465"><a name="p191814447465"></a><a name="p191814447465"></a>Compatibility</p>
186</td>
187<td class="cellrowborder" valign="top" width="80.96%" headers="mcps1.2.3.1.2 "><a name="ul186961827111612"></a><a name="ul186961827111612"></a><ul id="ul186961827111612"><li>Tests backward compatibility of an application with its own data, the forward and backward compatibility with the system, and the compatibility with different user data, such as audio file content of the player and smart SMS messages.</li><li>Tests system backward compatibility with its own data and the compatibility of common applications in the ecosystem.</li><li>Tests software compatibility with related hardware.</li></ul>
188</td>
189</tr>
190<tr id="row1782730124618"><td class="cellrowborder" valign="top" width="19.040000000000003%" headers="mcps1.2.3.1.1 "><p id="p13918144134614"><a name="p13918144134614"></a><a name="p13918144134614"></a>User</p>
191</td>
192<td class="cellrowborder" valign="top" width="80.96%" headers="mcps1.2.3.1.2 "><p id="p1291844494611"><a name="p1291844494611"></a><a name="p1291844494611"></a>Tests user experience of the object in real user scenarios. All conclusions and comments should come from the users, which are all subjective evaluation in this case.</p>
193</td>
194</tr>
195<tr id="row58243024617"><td class="cellrowborder" valign="top" width="19.040000000000003%" headers="mcps1.2.3.1.1 "><p id="p1291884474614"><a name="p1291884474614"></a><a name="p1291884474614"></a>Standard</p>
196</td>
197<td class="cellrowborder" valign="top" width="80.96%" headers="mcps1.2.3.1.2 "><p id="p0918124424614"><a name="p0918124424614"></a><a name="p0918124424614"></a>Tests the compliance with industry and company-specific standards, protocols, and specifications. The standards here do not include any security standards that should be classified into the security test.</p>
198</td>
199</tr>
200<tr id="row382830124619"><td class="cellrowborder" valign="top" width="19.040000000000003%" headers="mcps1.2.3.1.1 "><p id="p119181044164619"><a name="p119181044164619"></a><a name="p119181044164619"></a>Safety</p>
201</td>
202<td class="cellrowborder" valign="top" width="80.96%" headers="mcps1.2.3.1.2 "><p id="p1291818443468"><a name="p1291818443468"></a><a name="p1291818443468"></a>Tests the safety property of the tested object to avoid possible hazards to personal safety, health, and the object itself.</p>
203</td>
204</tr>
205<tr id="row1083153014465"><td class="cellrowborder" valign="top" width="19.040000000000003%" headers="mcps1.2.3.1.1 "><p id="p39187441469"><a name="p39187441469"></a><a name="p39187441469"></a>Resilience</p>
206</td>
207<td class="cellrowborder" valign="top" width="80.96%" headers="mcps1.2.3.1.2 "><p id="p891815444462"><a name="p891815444462"></a><a name="p891815444462"></a>Tests the resilience property of the tested object to ensure that it can withstand and maintain the defined running status (including downgrading) when being attacked, and recover from and adapt defense to the attacks to approach mission assurance.</p>
208</td>
209</tr>
210</tbody>
211</table>
212
213## Test Case Development Guidelines<a name="section3695134065513"></a>
214
215You should select the appropriate programming language and your target test framework to develop test cases.
216
217**Table  4**  Test frameworks and test case languages for different systems
218
219<a name="table4418343171415"></a>
220<table><thead align="left"><tr id="row34183435145"><th class="cellrowborder" valign="top" width="33.33333333333333%" id="mcps1.2.4.1.1"><p id="p941874311148"><a name="p941874311148"></a><a name="p941874311148"></a>System</p>
221</th>
222<th class="cellrowborder" valign="top" width="33.33333333333333%" id="mcps1.2.4.1.2"><p id="p1841804341413"><a name="p1841804341413"></a><a name="p1841804341413"></a>Test Framework</p>
223</th>
224<th class="cellrowborder" valign="top" width="33.33333333333333%" id="mcps1.2.4.1.3"><p id="p2418104311148"><a name="p2418104311148"></a><a name="p2418104311148"></a>Language</p>
225</th>
226</tr>
227</thead>
228<tbody><tr id="row8419164319148"><td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.2.4.1.1 "><p id="p7419194312143"><a name="p7419194312143"></a><a name="p7419194312143"></a>Mini</p>
229</td>
230<td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.2.4.1.2 "><p id="p10419124312145"><a name="p10419124312145"></a><a name="p10419124312145"></a>HCTest</p>
231</td>
232<td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.2.4.1.3 "><p id="p11419643191410"><a name="p11419643191410"></a><a name="p11419643191410"></a>C</p>
233</td>
234</tr>
235<tr id="row141915438147"><td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.2.4.1.1 "><p id="p441911436141"><a name="p441911436141"></a><a name="p441911436141"></a>Small</p>
236</td>
237<td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.2.4.1.2 "><p id="p541916432142"><a name="p541916432142"></a><a name="p541916432142"></a>HCPPTest</p>
238</td>
239<td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.2.4.1.3 "><p id="p54191643131416"><a name="p54191643131416"></a><a name="p54191643131416"></a>C++</p>
240</td>
241</tr>
242<tr id="row4419134341417"><td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.2.4.1.1 "><p id="p341964313143"><a name="p341964313143"></a><a name="p341964313143"></a>Standard</p>
243</td>
244<td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.2.4.1.2 "><p id="p10419443171416"><a name="p10419443171416"></a><a name="p10419443171416"></a>HJSUnit and HCPPTest</p>
245</td>
246<td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.2.4.1.3 "><p id="p9419143181414"><a name="p9419143181414"></a><a name="p9419143181414"></a>JavaScript and C++</p>
247</td>
248</tr>
249</tbody>
250</table>
251
252### C-based Test Case Development and Compilation \(for the Mini System\)<a name="section198193336544"></a>
253
254**Developing test cases for the mini system**
255
256The HCTest framework is used to support test cases developed with the C language. HCTest is enhanced and adapted based on the open-source test framework Unity.
257
2581.  Access the  **test/xts/acts**  repository where the test cases will be stored.
259
260    ```
261    ├── acts
262    │ └──subsystem_lite
263    │ │ └── module_hal
264    │ │ │ └── BUILD.gn
265    │ │ │ └── src
266    │ └──build_lite
267    │ │ └── BUILD.gn
268    ```
269
2702.  Write the test case in the  **src**  directory.
271
272    1 Import the test framework header file.
273
274    ```
275    #include "hctest.h"
276    ```
277
278    2. Use the  **LITE\_TEST\_SUIT**  macro to define names of the subsystem, module, and test suite.
279
280    ```
281    /**
282    * @brief  Registers a test suite named IntTestSuite.
283    * @param  test Subsystem name
284    * @param  example Module name
285    * @param  IntTestSuite Test suite name
286    */
287    LITE_TEST_SUIT(test, example, IntTestSuite);
288    ```
289
290    3. Define Setup and TearDown.
291
292    Format: Test suite name+Setup, Test suite name+TearDown.
293
294    The Setup and TearDown functions must exist, but function bodies can be empty.
295
296    4. Use the  **LITE\_TEST\_CASE**  macro to write the test case.
297
298    Three parameters are involved: test suite name, test case name, and test case properties \(including type, granularity, and level\).
299
300    ```
301    LITE_TEST_CASE(IntTestSuite, TestCase001, Function | MediumTest | Level1)
302    {
303      // Do something
304    };
305    ```
306
307    5. Use the  **RUN\_TEST\_SUITE**  macro to register the test suite.
308
309    ```
310    RUN_TEST_SUITE(IntTestSuite);
311    ```
312
3133.  Create the configuration file \(**BUILD.gn**\) of the test module.
314
315    Create a  **BUILD.gn**  \(example\) build file in each test module directory. Specify the name of the built static library and its dependent header file and library in the build file. The format is as follows:
316
317    ```
318    import("//test/xts/tools/lite/build/suite_lite.gni")
319    hctest_suite("ActsDemoTest") {
320        suite_name = "acts"
321        sources = [
322            "src/test_demo.c",
323        ]
324        include_dirs = [ ]
325        cflags = [ "-Wno-error" ]
326    }
327    ```
328
3294.  Add build options to the  **BUILD.gn**  file in the  **acts**  directory.
330
331    You need to add the test module to the  **test/xts/acts/build\_lite/BUILD.gn**  script in the  **acts**  directory.
332
333    ```
334    lite_component("acts") {
335        ...
336        if(board_name == "liteos_m") {
337            features += [
338                ...
339                "//xts/acts/subsystem_lite/module_hal:ActsDemoTest"
340            ]
341        }
342    }
343    ```
344
3455.  Run build commands.
346
347    Test suites are built along with version build. The ACTS is built together with the debug version.
348
349    >![](figures/icon-note.gif) **NOTE:**
350    >The ACTS build middleware is a static library, which will be linked to the image.
351
352
353### C-based Test Case Execution \(for the Mini System\)<a name="section13820233175418"></a>
354
355**Executing test cases for the mini system**
356
357Burn the image into the development board.
358
359**Executing the test**
360
3611.  Use a serial port tool to log in to the development board and save information about the serial port.
3622.  Restart the device and view serial port logs.
363
364**Analyzing the test result**
365
366View the serial port logs, whose format is as follows:
367
368The log for each test suite starts with  **Start to run test suite:**  and ends with  **xx Tests xx Failures xx Ignored**.
369
370### C++-based Test Case Development and Compilation \(for Standard and Small Systems\)<a name="section3822123311540"></a>
371
372**Developing test cases for small-system devices**  \(For examples of the standard system, go to the  **global/i18n\_standard directory**.\)
373
374The HCPPTest framework is enhanced and adapted based on the open-source framework Googletest.
375
3761.  Access the  **test/xts/acts**  repository where the test cases will be stored.
377
378    ```
379    ├── acts
380    │ └──subsystem_lite
381    │ │ └── module_posix
382    │ │ │ └── BUILD.gn
383    │ │ │ └── src
384    │ └──build_lite
385    │ │ └── BUILD.gn
386    ```
387
3882.  Write the test case in the  **src**  directory.
389
390    1. Import the test framework header file.
391
392    The following statement includes  **gtest.h**.
393
394    ```
395    #include "gtest/gtest.h"
396    ```
397
398    2. Define Setup and TearDown.
399
400    ```
401    using namespace std;
402    using namespace testing::ext;
403    class TestSuite: public testing::Test {
404    protected:
405    // Preset action of the test suite, which is executed before the first test case
406    static void SetUpTestCase(void){
407    }
408    // Test suite cleanup action, which is executed after the last test case
409    static void TearDownTestCase(void){
410    }
411    // Preset action of the test case
412    virtual void SetUp()
413    {
414    }
415    // Cleanup action of the test case
416    virtual void TearDown()
417    {
418    }
419    };
420    ```
421
422    3. Use the  **HWTEST**  or  **HWTEST\_F**  macro to write the test case.
423
424    **HWTEST**: definition of common test cases, including the test suite name, test case name, and case annotation.
425
426    **HWTEST\_F**: definition of SetUp and TearDown test cases, including the test suite name, test case name, and case annotation.
427
428    Three parameters are involved: test suite name, test case name, and test case properties \(including type, granularity, and level\).
429
430    ```
431    HWTEST_F(TestSuite, TestCase_0001, Function | MediumTest | Level1) {
432    // Do something
433    }
434    ```
435
4363.  Create a configuration file \(**BUILD.gn**\) of the test module.
437
438    Create a  **BUILD.gn**  build file in each test module directory. Specify the name of the built static library and its dependent header file and library in the build file. Each test module is independently built into a  **.bin**  executable file, which can be directly pushed to the development board for testing.
439
440    Example:
441
442    ```
443    import("//test/xts/tools/lite/build/suite_lite.gni")
444    hcpptest_suite("ActsDemoTest") {
445        suite_name = "acts"
446        sources = [
447            "src/TestDemo.cpp"
448        ]
449
450        include_dirs = [
451            "src",
452            ...
453        ]
454        deps = [
455            ...
456        ]
457        cflags = [ "-Wno-error" ]
458    }
459    ```
460
4614.  Add build options to the  **BUILD.gn**  file in the  **acts**  directory.
462
463    Add the test module to the  **test/xts/acts/build\_lite/BUILD.gn**  script in the  **acts**  directory.
464
465    ```
466     lite_component("acts") {
467    ...
468    else if(board_name == "liteos_a") {
469            features += [
470                ...
471                "//xts/acts/subsystem_lite/module_posix:ActsDemoTest"
472            ]
473        }
474    }
475    ```
476
4775.  Run build commands.
478
479    Test suites are built along with the version build. The ACTS is built together with the debug version.
480
481    >![](figures/icon-note.gif) **NOTE:**
482    >The ACTS for the small system is independently built to an executable file \(.bin\) and archived in the  **suites\\acts**  directory of the build result.
483
484
485### C++-based Test Case Execution \(for Standard and Small Systems\)<a name="section128222336544"></a>
486
487**Executing test cases for the small system**
488
489Currently, test cases are shared by the NFS and mounted to the development board for execution.
490
491**Setting up the environment**
492
4931.  Use a network cable or wireless network to connect the development board to your PC.
4942.  Configure the IP address, subnet mask, and gateway for the development board. Ensure that the development board and the PC are in the same network segment.
4953.  Install and register the NFS server on the PC and start the NFS service.
4964.  Run the  **mount**  command for the development board to ensure that the development board can access NFS shared files on the PC.
497
498    Format:  **mount** _NFS server IP address_**:/**_NFS shared directory_ **/**_development board directory_ **nfs**
499
500    Example:
501
502    ```
503    mount 192.168.1.10:/nfs /nfs nfs
504    ```
505
506
507**Executing test cases**
508
509Execute  **ActsDemoTest.bin**  to trigger test case execution, and analyze serial port logs generated after the execution is complete.
510
511### JavaScript-based Test Case Development \(for the Standard System\)<a name="section159801435165220"></a>
512
513The HJSUnit framework is used to support automated test of OpenHarmony apps that are developed using the JavaScript language based on the JS application framework.
514
515**Basic syntax of test cases**
516
517The test cases are developed with the JavaScript language and must meet the programming specifications of the language.
518
519**Table  5**
520
521<a name="table13980103565212"></a>
522<table><thead align="left"><tr id="row1098093545218"><th class="cellrowborder" valign="top" width="17.92179217921792%" id="mcps1.2.4.1.1"><p id="p49811235135214"><a name="p49811235135214"></a><a name="p49811235135214"></a>Syntax</p>
523</th>
524<th class="cellrowborder" valign="top" width="68.88688868886888%" id="mcps1.2.4.1.2"><p id="p898183565220"><a name="p898183565220"></a><a name="p898183565220"></a>Description</p>
525</th>
526<th class="cellrowborder" valign="top" width="13.19131913191319%" id="mcps1.2.4.1.3"><p id="p17981143512526"><a name="p17981143512526"></a><a name="p17981143512526"></a>Mandatory</p>
527</th>
528</tr>
529</thead>
530<tbody><tr id="row1598183515528"><td class="cellrowborder" valign="top" width="17.92179217921792%" headers="mcps1.2.4.1.1 "><p id="p139810358527"><a name="p139810358527"></a><a name="p139810358527"></a>beforeAll</p>
531</td>
532<td class="cellrowborder" valign="top" width="68.88688868886888%" headers="mcps1.2.4.1.2 "><p id="p198111352526"><a name="p198111352526"></a><a name="p198111352526"></a>Presets a test-suite-level action executed only once before all test cases are executed. You can pass the action function as the only parameter.</p>
533</td>
534<td class="cellrowborder" valign="top" width="13.19131913191319%" headers="mcps1.2.4.1.3 "><p id="p298114355529"><a name="p298114355529"></a><a name="p298114355529"></a>No</p>
535</td>
536</tr>
537<tr id="row11981103512529"><td class="cellrowborder" valign="top" width="17.92179217921792%" headers="mcps1.2.4.1.1 "><p id="p20981135135215"><a name="p20981135135215"></a><a name="p20981135135215"></a>afterAll</p>
538</td>
539<td class="cellrowborder" valign="top" width="68.88688868886888%" headers="mcps1.2.4.1.2 "><p id="p39811935115217"><a name="p39811935115217"></a><a name="p39811935115217"></a>Presets a test-suite-level clear action executed only once after all test cases are executed. You can pass the clear function as the only parameter.</p>
540</td>
541<td class="cellrowborder" valign="top" width="13.19131913191319%" headers="mcps1.2.4.1.3 "><p id="p998110354527"><a name="p998110354527"></a><a name="p998110354527"></a>No</p>
542</td>
543</tr>
544<tr id="row1298116359526"><td class="cellrowborder" valign="top" width="17.92179217921792%" headers="mcps1.2.4.1.1 "><p id="p898112359526"><a name="p898112359526"></a><a name="p898112359526"></a>beforeEach</p>
545</td>
546<td class="cellrowborder" valign="top" width="68.88688868886888%" headers="mcps1.2.4.1.2 "><p id="p149811335175215"><a name="p149811335175215"></a><a name="p149811335175215"></a>Presets a test-case-level action executed before each test case is executed. The number of execution times is the same as the number of test cases defined by <strong id="b32523248388"><a name="b32523248388"></a><a name="b32523248388"></a>it</strong>. You can pass the action function as the only parameter.</p>
547</td>
548<td class="cellrowborder" valign="top" width="13.19131913191319%" headers="mcps1.2.4.1.3 "><p id="p13981133585212"><a name="p13981133585212"></a><a name="p13981133585212"></a>No</p>
549</td>
550</tr>
551<tr id="row6982435115219"><td class="cellrowborder" valign="top" width="17.92179217921792%" headers="mcps1.2.4.1.1 "><p id="p19982133517525"><a name="p19982133517525"></a><a name="p19982133517525"></a>afterEach</p>
552</td>
553<td class="cellrowborder" valign="top" width="68.88688868886888%" headers="mcps1.2.4.1.2 "><p id="p1398213575219"><a name="p1398213575219"></a><a name="p1398213575219"></a>Presets a test-case-level clear action executed after each test case is executed. The number of execution times is the same as the number of test cases defined by <strong id="b10590142313399"><a name="b10590142313399"></a><a name="b10590142313399"></a>it</strong>. You can pass the clear function as the only parameter.</p>
554</td>
555<td class="cellrowborder" valign="top" width="13.19131913191319%" headers="mcps1.2.4.1.3 "><p id="p159821535195219"><a name="p159821535195219"></a><a name="p159821535195219"></a>No</p>
556</td>
557</tr>
558<tr id="row16982143513521"><td class="cellrowborder" valign="top" width="17.92179217921792%" headers="mcps1.2.4.1.1 "><p id="p598203510527"><a name="p598203510527"></a><a name="p598203510527"></a>describe</p>
559</td>
560<td class="cellrowborder" valign="top" width="68.88688868886888%" headers="mcps1.2.4.1.2 "><p id="p5982123595215"><a name="p5982123595215"></a><a name="p5982123595215"></a>Defines a test suite. You can pass two parameters: test suite name and test suite function. The <strong id="b7320205019400"><a name="b7320205019400"></a><a name="b7320205019400"></a>describe</strong> statement supports nesting. You can use <strong id="b138214222410"><a name="b138214222410"></a><a name="b138214222410"></a>beforeall</strong>, <strong id="b18677102314115"><a name="b18677102314115"></a><a name="b18677102314115"></a>beforeEach</strong>, <strong id="b1353142514113"><a name="b1353142514113"></a><a name="b1353142514113"></a>afterEach</strong>, and <strong id="b131041629204111"><a name="b131041629204111"></a><a name="b131041629204111"></a>afterAll</strong> in each <strong id="b590433484116"><a name="b590433484116"></a><a name="b590433484116"></a>describe</strong> statement.</p>
561</td>
562<td class="cellrowborder" valign="top" width="13.19131913191319%" headers="mcps1.2.4.1.3 "><p id="p898217352527"><a name="p898217352527"></a><a name="p898217352527"></a>Yes</p>
563</td>
564</tr>
565<tr id="row6982113518526"><td class="cellrowborder" valign="top" width="17.92179217921792%" headers="mcps1.2.4.1.1 "><p id="p17982123510526"><a name="p17982123510526"></a><a name="p17982123510526"></a>it</p>
566</td>
567<td class="cellrowborder" valign="top" width="68.88688868886888%" headers="mcps1.2.4.1.2 "><p id="p598211352522"><a name="p598211352522"></a><a name="p598211352522"></a>Defines a test case. You can pass three parameters: test case name, filter parameter, and test case function.</p>
568<p id="p5205769588"><a name="p5205769588"></a><a name="p5205769588"></a>Usage of the filter parameter:</p>
569<p id="p1545919528618"><a name="p1545919528618"></a><a name="p1545919528618"></a>The value of the filter parameter is a 32-bit integer. Setting different bits to <strong id="b045919521765"><a name="b045919521765"></a><a name="b045919521765"></a>1</strong> means different configurations:</p>
570<a name="ul6932113319395"></a><a name="ul6932113319395"></a><ul id="ul6932113319395"><li>bit 0: whether the filter parameter takes effect. <strong id="b1193293318395"><a name="b1193293318395"></a><a name="b1193293318395"></a>1</strong> means that the test case is used for the function test and other settings of the parameter do not take effect.</li><li>Bits 0-10: test case categories</li><li>Bits 16-18: test case scales</li><li>Bits 24-28: test levels</li></ul>
571<p id="p7965165151011"><a name="p7965165151011"></a><a name="p7965165151011"></a><strong id="b15148755145114"><a name="b15148755145114"></a><a name="b15148755145114"></a>Test case categories</strong>: Bits 0-10 indicate FUNCTION (function test), PERFORMANCE (performance test), POWER (power consumption test), RELIABILITY (reliability test), SECURITY (security compliance test), GLOBAL (integrity test), COMPATIBILITY (compatibility test), USER (user test), STANDARD (standard test), SAFETY (security feature test), and RESILIENCE (resilience test), respectively.</p>
572<p id="p199651555102"><a name="p199651555102"></a><a name="p199651555102"></a><strong id="b135908568519"><a name="b135908568519"></a><a name="b135908568519"></a>Test case scales</strong>: Bits 16-18 indicate SMALL (small-scale test), MEDIUM (medium-scale test), and LARGE (large-scale test), respectively.</p>
573<p id="p296545151020"><a name="p296545151020"></a><a name="p296545151020"></a><strong id="b12181058125111"><a name="b12181058125111"></a><a name="b12181058125111"></a>Test levels</strong>: Bits 24-28 indicate LEVEL0 (level-0 test), LEVEL1 (level-1 test), LEVEL2 (level-2 test), LEVEL3 (level-3 test), and LEVEL4 (level-4 test), respectively.</p>
574</td>
575<td class="cellrowborder" valign="top" width="13.19131913191319%" headers="mcps1.2.4.1.3 "><p id="p17601752115716"><a name="p17601752115716"></a><a name="p17601752115716"></a>Yes</p>
576</td>
577</tr>
578</tbody>
579</table>
580
581Use the standard syntax of Jasmine to write test cases. The ES6 specification is supported.
582
5831.  Store the test cases in the  **entry/src/main/js/test**  directory, whose structure is as follows:
584
585    ```
586    ├── BUILD.gn
587    │ └──entry
588    │ │ └──src
589    │ │ │ └──main
590    │ │ │ │ └──js
591    │ │ │ │ │ └──default
592    │ │ │ │ │ │ └──pages
593    │ │ │ │ │ │ │ └──index
594    │ │ │ │ │ │ │ │ └──index.js        # Entry file
595     │ │ │ │ │ └──test                  # Test code
596    │ │ │ └── resources                # HAP resources
597    │ │ │ └── config.json              # HAP configuration file
598    ```
599
6002.  Start the JS test framework and load test cases. The following is an example for  **index.js**.
601
602    ```
603    // Start the JS test framework and load test cases.
604    import {Core, ExpectExtend} from 'deccjsunit/index'
605
606    export default {
607        data: {
608            title: ""
609        },
610        onInit() {
611            this.title = this.$t('strings.world');
612        },
613        onShow() {
614            console.info('onShow finish')
615            const core = Core.getInstance()
616            const expectExtend = new ExpectExtend({
617                'id': 'extend'
618            })
619            core.addService('expect', expectExtend)
620            core.init()
621            const configService = core.getDefaultService('config')
622            configService.setConfig(this)
623            require('../../../test/List.test')
624            core.execute()
625        },
626        onReady() {
627        },
628    }
629    ```
630
6313.  Write a unit test case by referring to the following example:
632
633    ```
634    // Use HJSUnit to perform the unit test.
635    describe('appInfoTest', function () {
636        it('app_info_test_001', 0, function () {
637            var info = app.getInfo()
638            expect(info.versionName).assertEqual('1.0')
639            expect(info.versionCode).assertEqual('3')
640        })
641    })
642    ```
643
644
645### JavaScript-based Test Case Packaging \(for the Standard System\)<a name="section445519106559"></a>
646
647For details about how to build a HAP, see the JS application development guide of the standard system  [Building and Creating HAPs](https://developer.harmonyos.com/en/docs/documentation/doc-guides/build_overview-0000001055075201).
648
649

README_zh.md

1# XTS子系统<a name="ZH-CN_TOPIC_0000001117409671"></a>
2
3-   [简介](#section465982318513)
4-   [系统类型](#section125090457443)
5-   [目录](#section161941989596)
6-   [约束](#section119744591305)
7-   [使用说明](#section137768191623)
8-   [用例开发指导](#section3695134065513)
9    -   [C语言用例开发编译指导(适用于轻量系统产品用例开发)](#section198193336544)
10    -   [C语言用例执行指导(适用于轻量系统产品用例开发)](#section13820233175418)
11    -   [C++语言用例开发编译指导(适用于小型系统、标准系统用例开发)](#section3822123311540)
12    -   [C++语言用例执行指导(适用于小型系统、标准系统用例开发)](#section128222336544)
13    -   [JS语言用例开发指导(适用于标准系统)](#section159801435165220)
14    -   [JS语言用例编译打包指导(适用于标准系统)](#section445519106559)
15
16-   [相关仓](#section1371113476307)
17
18## 简介<a name="section465982318513"></a>
19
20XTS子系统是OpenHarmony生态认证测试套件的集合,当前包括acts(application compatibility test suite)应用兼容性测试套件,后续会拓展dcts(device compatibility test suite)设备兼容性测试套件等。
21
22XTS子系统当前包括acts与tools软件包:
23
24-   acts,存放acts相关测试用例源码与配置文件,其目的是帮助终端设备厂商尽早发现软件与OpenHarmony的不兼容性,确保软件在整个开发过程中满足OpenHarmony的兼容性要求。
25-   tools,存放acts相关测试用例开发框架。
26
27## 系统类型<a name="section125090457443"></a>
28
29OpenHarmony支持如下几种系统类型:
30
31-   轻量系统(mini system)
32
33    面向MCU类处理器例如Arm Cortex-M、RISC-V 32位的设备,硬件资源极其有限,支持的设备最小内存为128KiB,可以提供多种轻量级网络协议,轻量级的图形框架,以及丰富的IOT总线读写部件等。可支撑的产品如智能家居领域的连接类模组、传感器设备、穿戴类设备等。
34
35-   小型系统(small system)
36
37    面向应用处理器例如Arm Cortex-A的设备,支持的设备最小内存为1MiB,可以提供更高的安全能力、标准的图形框架、视频编解码的多媒体能力。可支撑的产品如智能家居领域的IP Camera、电子猫眼、路由器以及智慧出行领域的行车记录仪等。
38
39-   标准系统(standard system)
40
41    面向应用处理器例如Arm Cortex-A的设备,支持的设备最小内存为128MiB,可以提供增强的交互能力、3D GPU以及硬件合成能力、更多控件以及动画效果更丰富的图形能力、完整的应用框架。可支撑的产品如高端的冰箱显示屏。
42
43
44## 目录<a name="section161941989596"></a>
45
46```
47/test/xts
48├── acts                # 测试代码存放目录
49│   └── subsystem       # 标准系统子系统测试用例源码存放目录
50│   └── subsystem_lite  # 轻量系统、小型系统子系统测试用例源码存放目录
51│   └── BUILD.gn        # 标准系统测试用例编译配置
52│   └── build_lite      # 轻量系统、小型系统测试用例编译配置存放目录
53│       └── BUILD.gn    # 轻量系统、小型系统测试用例编译配置
54└── tools               # 测试工具代码存放目录
55```
56
57## 约束<a name="section119744591305"></a>
58
59轻量系统用例开发语言是C,小型系统用例开发语言是C++。
60
61## 使用说明<a name="section137768191623"></a>
62
63**表 1**  用例级别说明
64
65<a name="table12856113719456"></a>
66<table><thead align="left"><tr id="row88561737114517"><th class="cellrowborder" valign="top" width="33.333333333333336%" id="mcps1.2.4.1.1"><p id="p54711456452"><a name="p54711456452"></a><a name="p54711456452"></a>级别名称</p>
67</th>
68<th class="cellrowborder" valign="top" width="33.283328332833285%" id="mcps1.2.4.1.2"><p id="p114834544518"><a name="p114834544518"></a><a name="p114834544518"></a>基本定义</p>
69</th>
70<th class="cellrowborder" valign="top" width="33.383338333833386%" id="mcps1.2.4.1.3"><p id="p348154574518"><a name="p348154574518"></a><a name="p348154574518"></a>测试范围</p>
71</th>
72</tr>
73</thead>
74<tbody><tr id="row78561137134514"><td class="cellrowborder" valign="top" width="33.333333333333336%" headers="mcps1.2.4.1.1 "><p id="p17481345124512"><a name="p17481345124512"></a><a name="p17481345124512"></a>Level0</p>
75</td>
76<td class="cellrowborder" valign="top" width="33.283328332833285%" headers="mcps1.2.4.1.2 "><p id="p1548945204514"><a name="p1548945204514"></a><a name="p1548945204514"></a>冒烟</p>
77</td>
78<td class="cellrowborder" valign="top" width="33.383338333833386%" headers="mcps1.2.4.1.3 "><p id="p174824517456"><a name="p174824517456"></a><a name="p174824517456"></a>验证关键功能点基本功能/最基本DFX属性在最常见输入下的表现,通过表示功能基本可运行。</p>
79</td>
80</tr>
81<tr id="row28563372451"><td class="cellrowborder" valign="top" width="33.333333333333336%" headers="mcps1.2.4.1.1 "><p id="p448445144512"><a name="p448445144512"></a><a name="p448445144512"></a>Level1</p>
82</td>
83<td class="cellrowborder" valign="top" width="33.283328332833285%" headers="mcps1.2.4.1.2 "><p id="p44813452452"><a name="p44813452452"></a><a name="p44813452452"></a>基本</p>
84</td>
85<td class="cellrowborder" valign="top" width="33.383338333833386%" headers="mcps1.2.4.1.3 "><p id="p648184584514"><a name="p648184584514"></a><a name="p648184584514"></a>验证各功能点基本功能/基本DFX属性在常见输入下的表现,通过表示功能基本可测试。</p>
86</td>
87</tr>
88<tr id="row12856137204514"><td class="cellrowborder" valign="top" width="33.333333333333336%" headers="mcps1.2.4.1.1 "><p id="p164834520453"><a name="p164834520453"></a><a name="p164834520453"></a>Level2</p>
89</td>
90<td class="cellrowborder" valign="top" width="33.283328332833285%" headers="mcps1.2.4.1.2 "><p id="p148245184511"><a name="p148245184511"></a><a name="p148245184511"></a>重要</p>
91</td>
92<td class="cellrowborder" valign="top" width="33.383338333833386%" headers="mcps1.2.4.1.3 "><p id="p348945124510"><a name="p348945124510"></a><a name="p348945124510"></a>验证各功能点的基本功能/基本DFX属性在常规输入/常见异常情况下的表现,通过表示功能基本正常可用,可开展Beta。</p>
93</td>
94</tr>
95<tr id="row48571137204514"><td class="cellrowborder" valign="top" width="33.333333333333336%" headers="mcps1.2.4.1.1 "><p id="p7481545184513"><a name="p7481545184513"></a><a name="p7481545184513"></a>Level3</p>
96</td>
97<td class="cellrowborder" valign="top" width="33.283328332833285%" headers="mcps1.2.4.1.2 "><p id="p1748184514455"><a name="p1748184514455"></a><a name="p1748184514455"></a>一般</p>
98</td>
99<td class="cellrowborder" valign="top" width="33.383338333833386%" headers="mcps1.2.4.1.3 "><p id="p8481245104519"><a name="p8481245104519"></a><a name="p8481245104519"></a>验证各功能点的全部功能/全部DFX属性在各种常规/非常规输入组合下,或各种正常/异常预置条件组合下的表现。</p>
100</td>
101</tr>
102<tr id="row14857133712451"><td class="cellrowborder" valign="top" width="33.333333333333336%" headers="mcps1.2.4.1.1 "><p id="p1248144515456"><a name="p1248144515456"></a><a name="p1248144515456"></a>Level4</p>
103</td>
104<td class="cellrowborder" valign="top" width="33.283328332833285%" headers="mcps1.2.4.1.2 "><p id="p94804514519"><a name="p94804514519"></a><a name="p94804514519"></a>生僻</p>
105</td>
106<td class="cellrowborder" valign="top" width="33.383338333833386%" headers="mcps1.2.4.1.3 "><p id="p1248445164516"><a name="p1248445164516"></a><a name="p1248445164516"></a>验证关键功能点在极端异常预置条件下、用户难以触及的异常输入组合下的表现。</p>
107</td>
108</tr>
109</tbody>
110</table>
111
112**表 2**  用例粒度说明
113
114<a name="table1690733521014"></a>
115<table><thead align="left"><tr id="row9907143516105"><th class="cellrowborder" valign="top" width="19.591959195919593%" id="mcps1.2.4.1.1"><p id="p1141312416102"><a name="p1141312416102"></a><a name="p1141312416102"></a>用例规模</p>
116</th>
117<th class="cellrowborder" valign="top" width="35.17351735173517%" id="mcps1.2.4.1.2"><p id="p34131416109"><a name="p34131416109"></a><a name="p34131416109"></a>被测试对象</p>
118</th>
119<th class="cellrowborder" valign="top" width="45.23452345234523%" id="mcps1.2.4.1.3"><p id="p12413141171010"><a name="p12413141171010"></a><a name="p12413141171010"></a>测试环境</p>
120</th>
121</tr>
122</thead>
123<tbody><tr id="row2907335181017"><td class="cellrowborder" valign="top" width="19.591959195919593%" headers="mcps1.2.4.1.1 "><p id="p6414134117109"><a name="p6414134117109"></a><a name="p6414134117109"></a>LargeTest</p>
124</td>
125<td class="cellrowborder" valign="top" width="35.17351735173517%" headers="mcps1.2.4.1.2 "><p id="p20414104113101"><a name="p20414104113101"></a><a name="p20414104113101"></a>业务功能/全场景特性/整机及场景级DFX</p>
126</td>
127<td class="cellrowborder" valign="top" width="45.23452345234523%" headers="mcps1.2.4.1.3 "><p id="p5414841121013"><a name="p5414841121013"></a><a name="p5414841121013"></a>尽量使用贴近真实的环境设备</p>
128</td>
129</tr>
130<tr id="row10907635131015"><td class="cellrowborder" valign="top" width="19.591959195919593%" headers="mcps1.2.4.1.1 "><p id="p19414134117104"><a name="p19414134117104"></a><a name="p19414134117104"></a>MediumTest</p>
131</td>
132<td class="cellrowborder" valign="top" width="35.17351735173517%" headers="mcps1.2.4.1.2 "><p id="p114141241141018"><a name="p114141241141018"></a><a name="p114141241141018"></a>模块/子系统集成至设备后的功能/DFX</p>
133</td>
134<td class="cellrowborder" valign="top" width="45.23452345234523%" headers="mcps1.2.4.1.3 "><p id="p14414941111015"><a name="p14414941111015"></a><a name="p14414941111015"></a>使用真实的单设备进行验证,可进行消息模拟,尽量不对函数进行MOCK</p>
135</td>
136</tr>
137<tr id="row1990713353100"><td class="cellrowborder" valign="top" width="19.591959195919593%" headers="mcps1.2.4.1.1 "><p id="p641414110109"><a name="p641414110109"></a><a name="p641414110109"></a>SmallTest</p>
138</td>
139<td class="cellrowborder" valign="top" width="35.17351735173517%" headers="mcps1.2.4.1.2 "><p id="p54141541181018"><a name="p54141541181018"></a><a name="p54141541181018"></a>模块/类/函数</p>
140</td>
141<td class="cellrowborder" valign="top" width="45.23452345234523%" headers="mcps1.2.4.1.3 "><p id="p1841494131013"><a name="p1841494131013"></a><a name="p1841494131013"></a>在开发者个人环境进行测试,尽量不依赖其他模块,存在大量的MOCK</p>
142</td>
143</tr>
144</tbody>
145</table>
146
147**表 3**  测试类型说明
148
149<a name="table18811230124619"></a>
150<table><thead align="left"><tr id="row48163019466"><th class="cellrowborder" valign="top" width="19.040000000000003%" id="mcps1.2.3.1.1"><p id="p1791784418465"><a name="p1791784418465"></a><a name="p1791784418465"></a>测试类型名称</p>
151</th>
152<th class="cellrowborder" valign="top" width="80.96%" id="mcps1.2.3.1.2"><p id="p2917164444614"><a name="p2917164444614"></a><a name="p2917164444614"></a>测试类型定义</p>
153</th>
154</tr>
155</thead>
156<tbody><tr id="row682630104615"><td class="cellrowborder" valign="top" width="19.040000000000003%" headers="mcps1.2.3.1.1 "><p id="p1091784414469"><a name="p1091784414469"></a><a name="p1091784414469"></a>Function</p>
157</td>
158<td class="cellrowborder" valign="top" width="80.96%" headers="mcps1.2.3.1.2 "><p id="p16917344104618"><a name="p16917344104618"></a><a name="p16917344104618"></a>验证被测对象提供给用户的业务功能实现正确性的测试项,这里的“用户”可以是终端用户或开发者,功能包括业务功能及平台功能</p>
159</td>
160</tr>
161<tr id="row1821930154611"><td class="cellrowborder" valign="top" width="19.040000000000003%" headers="mcps1.2.3.1.1 "><p id="p591714474612"><a name="p591714474612"></a><a name="p591714474612"></a>Performance</p>
162</td>
163<td class="cellrowborder" valign="top" width="80.96%" headers="mcps1.2.3.1.2 "><p id="p15917154410463"><a name="p15917154410463"></a><a name="p15917154410463"></a>验证被测对象在特定预置条件/负载模型下的处理能力的测试项,“处理能力”一般以单位时间内可处理的业务量来衡量,如呼叫/秒,帧率/秒,事件处理量/秒等</p>
164</td>
165</tr>
166<tr id="row13821030104616"><td class="cellrowborder" valign="top" width="19.040000000000003%" headers="mcps1.2.3.1.1 "><p id="p691711440467"><a name="p691711440467"></a><a name="p691711440467"></a>Power</p>
167</td>
168<td class="cellrowborder" valign="top" width="80.96%" headers="mcps1.2.3.1.2 "><p id="p159171544104616"><a name="p159171544104616"></a><a name="p159171544104616"></a>验证被测对象在特定预置条件/负载模型下在一定时间内能源消耗量的测试项</p>
169</td>
170</tr>
171<tr id="row6821330114618"><td class="cellrowborder" valign="top" width="19.040000000000003%" headers="mcps1.2.3.1.1 "><p id="p13917164454612"><a name="p13917164454612"></a><a name="p13917164454612"></a>Reliability</p>
172</td>
173<td class="cellrowborder" valign="top" width="80.96%" headers="mcps1.2.3.1.2 "><p id="p11917194416465"><a name="p11917194416465"></a><a name="p11917194416465"></a>验证被测对象在正常/异常输入情况下,或业务量压力和长时间连续运行压力情况下业务表现的测试项,含稳定性、压力、故障注入、Monkey测试项</p>
174</td>
175</tr>
176<tr id="row11821930184612"><td class="cellrowborder" valign="top" width="19.040000000000003%" headers="mcps1.2.3.1.1 "><p id="p1691774474618"><a name="p1691774474618"></a><a name="p1691774474618"></a>Security</p>
177</td>
178<td class="cellrowborder" valign="top" width="80.96%" headers="mcps1.2.3.1.2 "><p id="p1791784410463"><a name="p1791784410463"></a><a name="p1791784410463"></a>验证系统对恶意威胁的防护能力,威胁包括但不限于未授权访问、使用、泄露、破坏、修改、毁灭,以保障信息的机密性、完整性和可用性; 验证系统对用户隐私的保护能力,保障用户的隐私数据被收集、使用、保有、披露和处置符合法律规范,保障用户的隐私权; 验证对各类安全规范的遵从情况,如安全设计规范、安全红线、工信部安全认证规范等,保障安全相关法律法规的合规。</p>
179</td>
180</tr>
181<tr id="row16825307467"><td class="cellrowborder" valign="top" width="19.040000000000003%" headers="mcps1.2.3.1.1 "><p id="p129188444462"><a name="p129188444462"></a><a name="p129188444462"></a>Global</p>
182</td>
183<td class="cellrowborder" valign="top" width="80.96%" headers="mcps1.2.3.1.2 "><p id="p179186444465"><a name="p179186444465"></a><a name="p179186444465"></a>验证被测对象在是否具有国际化数据支持和本地化能力的测试项,包括语言显示、输入/输出习惯、时间显示、区域特性如货币时间禁忌等等</p>
184</td>
185</tr>
186<tr id="row08211308464"><td class="cellrowborder" valign="top" width="19.040000000000003%" headers="mcps1.2.3.1.1 "><p id="p191814447465"><a name="p191814447465"></a><a name="p191814447465"></a>Compatibility</p>
187</td>
188<td class="cellrowborder" valign="top" width="80.96%" headers="mcps1.2.3.1.2 "><p id="p99181344144613"><a name="p99181344144613"></a><a name="p99181344144613"></a>当被测对象为应用时,包括被测对象对于自身数据的后向兼容性、对于系统的前后向兼容性、对于不同用户数据(如播放器之音频文件格式/智能短信之用户短信内容)的兼容性测试项; 当被测对象为系统时,包括被测系统对于系统自身数据的后向兼容性、以及对于生态中常用应用的兼容性测试项;当被测对象为软件时,包括被测系统对于相关的硬件的兼容性;</p>
189</td>
190</tr>
191<tr id="row1782730124618"><td class="cellrowborder" valign="top" width="19.040000000000003%" headers="mcps1.2.3.1.1 "><p id="p13918144134614"><a name="p13918144134614"></a><a name="p13918144134614"></a>User</p>
192</td>
193<td class="cellrowborder" valign="top" width="80.96%" headers="mcps1.2.3.1.2 "><p id="p1291844494611"><a name="p1291844494611"></a><a name="p1291844494611"></a>验证被测对象在真实用户场景下的用户体验感受的测试项,注意此种情况下没有客观的“正确”与“失败”,所有的结论及评价都应该来自于用户</p>
194</td>
195</tr>
196<tr id="row58243024617"><td class="cellrowborder" valign="top" width="19.040000000000003%" headers="mcps1.2.3.1.1 "><p id="p1291884474614"><a name="p1291884474614"></a><a name="p1291884474614"></a>Standard</p>
197</td>
198<td class="cellrowborder" valign="top" width="80.96%" headers="mcps1.2.3.1.2 "><p id="p0918124424614"><a name="p0918124424614"></a><a name="p0918124424614"></a>验证被测对象对于行业及公司内标准/协议/规范的遵从情况的测试项,注意此处的“标准”不包含任何安全标准,针对安全标准的测试项划归为“安全测试”类型</p>
199</td>
200</tr>
201<tr id="row382830124619"><td class="cellrowborder" valign="top" width="19.040000000000003%" headers="mcps1.2.3.1.1 "><p id="p119181044164619"><a name="p119181044164619"></a><a name="p119181044164619"></a>Safety</p>
202</td>
203<td class="cellrowborder" valign="top" width="80.96%" headers="mcps1.2.3.1.2 "><p id="p1291818443468"><a name="p1291818443468"></a><a name="p1291818443468"></a>验证被测对象的Safety属性,避免产品可能对人身安全、健康以及产品本身带来的危害。</p>
204</td>
205</tr>
206<tr id="row1083153014465"><td class="cellrowborder" valign="top" width="19.040000000000003%" headers="mcps1.2.3.1.1 "><p id="p39187441469"><a name="p39187441469"></a><a name="p39187441469"></a>Resilience</p>
207</td>
208<td class="cellrowborder" valign="top" width="80.96%" headers="mcps1.2.3.1.2 "><p id="p891815444462"><a name="p891815444462"></a><a name="p891815444462"></a>验证被测对象的韧性属性,确保系统受攻击时承受并保持在有定义的运行状态(包括降级)、恢复并适应攻击以保障Mission达成。</p>
209</td>
210</tr>
211</tbody>
212</table>
213
214## 用例开发指导<a name="section3695134065513"></a>
215
216根据测试系统选择测试框架和对应测试用例语言。
217
218**表 4**  系统和测试框架、开发语言对应关系
219
220<a name="table4418343171415"></a>
221<table><thead align="left"><tr id="row34183435145"><th class="cellrowborder" valign="top" width="33.33333333333333%" id="mcps1.2.4.1.1"><p id="p941874311148"><a name="p941874311148"></a><a name="p941874311148"></a>系统</p>
222</th>
223<th class="cellrowborder" valign="top" width="33.33333333333333%" id="mcps1.2.4.1.2"><p id="p1841804341413"><a name="p1841804341413"></a><a name="p1841804341413"></a>测试框架</p>
224</th>
225<th class="cellrowborder" valign="top" width="33.33333333333333%" id="mcps1.2.4.1.3"><p id="p2418104311148"><a name="p2418104311148"></a><a name="p2418104311148"></a>语言</p>
226</th>
227</tr>
228</thead>
229<tbody><tr id="row8419164319148"><td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.2.4.1.1 "><p id="p7419194312143"><a name="p7419194312143"></a><a name="p7419194312143"></a>轻量系统</p>
230</td>
231<td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.2.4.1.2 "><p id="p10419124312145"><a name="p10419124312145"></a><a name="p10419124312145"></a>hctest</p>
232</td>
233<td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.2.4.1.3 "><p id="p11419643191410"><a name="p11419643191410"></a><a name="p11419643191410"></a>c</p>
234</td>
235</tr>
236<tr id="row141915438147"><td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.2.4.1.1 "><p id="p441911436141"><a name="p441911436141"></a><a name="p441911436141"></a>小型系统</p>
237</td>
238<td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.2.4.1.2 "><p id="p541916432142"><a name="p541916432142"></a><a name="p541916432142"></a>hcpptest</p>
239</td>
240<td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.2.4.1.3 "><p id="p54191643131416"><a name="p54191643131416"></a><a name="p54191643131416"></a>c++</p>
241</td>
242</tr>
243<tr id="row4419134341417"><td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.2.4.1.1 "><p id="p341964313143"><a name="p341964313143"></a><a name="p341964313143"></a>标准系统</p>
244</td>
245<td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.2.4.1.2 "><p id="p10419443171416"><a name="p10419443171416"></a><a name="p10419443171416"></a>HJSUnit、hcpptest</p>
246</td>
247<td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.2.4.1.3 "><p id="p9419143181414"><a name="p9419143181414"></a><a name="p9419143181414"></a>js、c++</p>
248</td>
249</tr>
250</tbody>
251</table>
252
253### C语言用例开发编译指导(适用于轻量系统产品用例开发)<a name="section198193336544"></a>
254
255**示例:轻量系统测试用例开发**
256
257当前使用的测试框架是hctest,hctest测试框架支持使用C语言编写测试用例,是在开源测试框架unity的基础上进行增强和适配。
258
2591.  用例目录规范:测试用例存储到test/xts/acts仓中
260
261    ```
262    ├── acts
263    │ └──subsystem_lite
264    │ │ └── module_hal
265    │ │ │ └── BUILD.gn
266    │ │ │ └── src
267    │ └──build_lite
268    │ │ └── BUILD.gn
269    ```
270
2712.  src目录下用例编写样例。
272
273    1.引用测试框架
274
275    ```
276    #include "hctest.h"
277    ```
278
279    2. 使用宏定义LITE\_TEST\_SUIT定义子系统、模块、测试套件名称
280
281    ```
282    /**
283    * @brief  register a test suit named "IntTestSuite"
284    * @param  test subsystem name
285    * @param  example module name
286    * @param  IntTestSuite test suit name
287    */
288    LITE_TEST_SUIT(test, example, IntTestSuite);
289    ```
290
291    3. 定义Setup与TearDown
292
293    命名方式:测试套件名称+Setup,测试套件名称+TearDown。
294
295    Setup与TearDown必须存在,可以为空函数。
296
297    4. 使用宏定义LITE\_TEST\_CASE写测试用例
298
299    包括三个参数:测试套件名称,测试用例名称,用例属性(测试类型、用例粒度、用例级别)。
300
301    ```
302    LITE_TEST_CASE(IntTestSuite, TestCase001, Function | MediumTest | Level1)
303    {
304      //do something
305    };
306    ```
307
308    5. 使用宏定义 RUN\_TEST\_SUITE注册测试套件
309
310    ```
311    RUN_TEST_SUITE(IntTestSuite);
312    ```
313
3143.  测试模块的配置文件(BUILD.gn)样例:
315
316    在每个测试模块目录下新建BUILD.gn编译文件,用于指定编译后静态库的名称、依赖的头文件、依赖的库等;具体写法如下:
317
318    ```
319    import("//test/xts/tools/lite/build/suite_lite.gni")
320    hctest_suite("ActsDemoTest") {
321        suite_name = "acts"
322        sources = [
323            "src/test_demo.c",
324        ]
325        include_dirs = [ ]
326        cflags = [ "-Wno-error" ]
327    }
328    ```
329
3304.  acts下BUILD.gn增加编译选项。
331
332    需要将测试模块加入到acts目录下的编译脚本中,编译脚本路径:test/xts/acts/build\_lite/BUILD.gn333
334    ```
335    lite_component("acts") {
336        ...
337        if(board_name == "liteos_m") {
338            features += [
339                ...
340                "//xts/acts/subsystem_lite/module_hal:ActsDemoTest"
341            ]
342        }
343    }
344    ```
345
3465.  测试套件编译命令_两种编译方式。
347
348    方式一:
349
350    ```
351    ./test/xts/tools/lite/build.sh product=wifiiot xts=acts
352    ```
353
354    方式二:
355
356    ```
357    hb set
358    选择 设备类型
359    hb build --gn-args build_xts=true
360    (注):若不追加--gn-args build_xts=true,不会编译acts测试套件。
361    ```
362
363    >![](figures/icon-note.gif) **说明:**
364    >acts测试套件编译中间件为静态库,最终链接到版本镜像中 。
365
366
367### C语言用例执行指导(适用于轻量系统产品用例开发)<a name="section13820233175418"></a>
368
369**示例:轻量系统测试用例执行**
370
371将版本镜像烧录进开发板。
372
373**测试步骤**
374
3751.  使用串口工具登录开发板,并保存串口打印信息。
3762.  重启设备,查看串口日志。
377
378**测试结果分析指导**
379
380基于串口打印日志进行分析;
381
382每个测试套件执行以Start to run test suite开始,以xx Tests xx Failures xx Ignored结束。
383
384### C++语言用例开发编译指导(适用于小型系统、标准系统用例开发)<a name="section3822123311540"></a>
385
386**示例:小型系统测试用例开发**(标准系统参考具体样例目录:global/i18n\_standard)
387
388当前使用的测试框架是hcpptest,hcpptest测试框架是在开源的googletest测试框架的基础上进行的增强和适配。
389
3901.  规范用例目录:测试用例存储到test/xts/acts仓中。
391
392    ```
393    ├── acts
394    │ └──subsystem_lite
395    │ │ └── module_posix
396    │ │ │ └── BUILD.gn
397    │ │ │ └── src
398    │ └──build_lite
399    │ │ └── BUILD.gn
400    ```
401
4022.  测试模块src下用例编写样例:
403
404    1. 引用测试框架:
405
406    需要引用gtest.h  如:\#include "gtest/gtest.h"
407
408    ```
409    #include "gtest/gtest.h"
410    ```
411
412    2. 定义Setup与TearDown
413
414    ```
415    using namespace std;
416    using namespace testing::ext;
417    class TestSuite: public testing::Test {
418    protected:
419    // Preset action of the test suite, which is executed before the first test case
420    static void SetUpTestCase(void){
421    }
422    // Test suite cleanup action, which is executed after the last test case
423    static void TearDownTestCase(void){
424    }
425    // Preset action of the test case
426    virtual void SetUp()
427    {
428    }
429    // Cleanup action of the test case
430    virtual void TearDown()
431    {
432    }
433    };
434    ```
435
436    3. 使用宏定义HWTEST或HWTEST\_F写测试用例
437
438    普通测试用例的定义:HWTEST(测试套名称, 测试用例名称, 用例标注)。
439
440    包含SetUp和TearDown的测试用例的定义 :HWTEST\_F(测试套名称, 测试用例名称,用例标注)。
441
442    宏定义包括三个参数:测试套件名称,测试用例名称,用例属性(测试类型、用例粒度、用例级别)。
443
444    ```
445    HWTEST_F(TestSuite, TestCase_0001, Function | MediumTest | Level1) {
446    // do something
447    }
448    ```
449
4503.  测试模块下用例配置文件(BUILD.gn)样例:
451
452    每个测试模块目录下新建BUILD.gn编译文件,用于指定编译后可执行文件的名称、依赖的头文件、依赖的库等;具体写法如下。每个测试模块将独立编译成.bin可执行文件, 该文件可直接push到单板上进行测试。
453
454    举例:
455
456    ```
457    import("//test/xts/tools/lite/build/suite_lite.gni")
458    hcpptest_suite("ActsDemoTest") {
459        suite_name = "acts"
460        sources = [
461            "src/TestDemo.cpp"
462        ]
463
464        include_dirs = [
465            "src",
466            ...
467        ]
468        deps = [
469            ...
470        ]
471        cflags = [ "-Wno-error" ]
472    }
473
474    ```
475
4764.  acts目录下增加编译选项(BUILD.gn)样例:
477
478    将测试模块加入到acts目录下的编译脚本中,编译脚本为:test/xts/acts/build\_lite/BUILD.gn479
480    ```
481     lite_component("acts") {
482    ...
483    else if(board_name == "liteos_a") {
484            features += [
485                ...
486                "//xts/acts/subsystem_lite/module_posix:ActsDemoTest"
487            ]
488        }
489    }
490    ```
491
4925.  测试套件编译命令_两种编译方式。
493
494    L1_LiteOS:
495
496    ```
497    方式一:
498    python3 build.py -p ipcamera_hispark_taurus@hisilicon --gn-args build_xts=true
499    方式二:
500    hb set
501    选择 设备类型
502    hb build --gn-args build_xts=true
503    (注):若不追加--gn-args build_xts=true,不会编译acts测试套件。
504    ```
505
506    L1_Linux:
507
508    ```
509    方式一:
510    python3 build.py -p ipcamera_hispark_taurus_linux@hisilicon --gn-args build_xts=true
511    方式二:
512    hb set
513    选择 设备类型
514    hb build --gn-args build_xts=true
515    (注):若不追加--gn-args build_xts=true,不会编译acts测试套件。
516    ```
517
518    >![](figures/icon-note.gif) **说明:**
519    >小型系统acts独立编译成可执行文件(bin格式), 在编译产物的suites\\acts目录下归档。
520
521
522### C++语言用例执行指导(适用于小型系统、标准系统用例开发)<a name="section128222336544"></a>
523
524**示例:小型系统测试用例执行**
525
526目前的用例执行采用nfs共享的方式,mount到单板去执行。
527
528**环境搭建**
529
5301.  使用网线或无线网络将开发板与PC进行连接。
5312.  开发板配置IP、子网掩码、网关,确保开发板与PC处于同一个网段。
5323.  PC安装nfs服务器并完成注册,启动nfs服务。
5334.  开发板配置mount命令,确保开发板可以访问PC端的nfs共享文件。
534
535    格式:mount \[nfs服务器IP\]:\[/nfs共享目录\] \[/开发板目录\] nfs
536
537    举例:
538
539    ```
540    mount 192.168.1.10:/nfs /nfs nfs
541    ```
542
543
544**用例执行**
545
546测试套件执行 ActsDemoTest.bin 触发用例执行,基于串口打印日志进行分析。
547
548### JS语言用例开发指导(适用于标准系统)<a name="section159801435165220"></a>
549
550当前使用的测试框架是HJSUnit,用于支撑OpenHarmony application测试(特指基于JS应用框架使用 Javascript 语言开发的 APP)进行自动化测试。
551
552**用例编写基础语法**
553
554测试用例为 js 语言,必须满足 JavaScript 语言编程规范:
555
556**表 5**
557
558<a name="table13980103565212"></a>
559<table><thead align="left"><tr id="row1098093545218"><th class="cellrowborder" valign="top" width="17.92179217921792%" id="mcps1.2.4.1.1"><p id="p49811235135214"><a name="p49811235135214"></a><a name="p49811235135214"></a>用例语法</p>
560</th>
561<th class="cellrowborder" valign="top" width="68.88688868886888%" id="mcps1.2.4.1.2"><p id="p898183565220"><a name="p898183565220"></a><a name="p898183565220"></a>描述</p>
562</th>
563<th class="cellrowborder" valign="top" width="13.19131913191319%" id="mcps1.2.4.1.3"><p id="p17981143512526"><a name="p17981143512526"></a><a name="p17981143512526"></a>要求</p>
564</th>
565</tr>
566</thead>
567<tbody><tr id="row1598183515528"><td class="cellrowborder" valign="top" width="17.92179217921792%" headers="mcps1.2.4.1.1 "><p id="p139810358527"><a name="p139810358527"></a><a name="p139810358527"></a>beforeAll</p>
568</td>
569<td class="cellrowborder" valign="top" width="68.88688868886888%" headers="mcps1.2.4.1.2 "><p id="p198111352526"><a name="p198111352526"></a><a name="p198111352526"></a>测试套级别的预置条件,在所有测试用例开始前执行且仅执行一次,支持一个参数:预置动作函数</p>
570</td>
571<td class="cellrowborder" valign="top" width="13.19131913191319%" headers="mcps1.2.4.1.3 "><p id="p298114355529"><a name="p298114355529"></a><a name="p298114355529"></a>可选</p>
572</td>
573</tr>
574<tr id="row11981103512529"><td class="cellrowborder" valign="top" width="17.92179217921792%" headers="mcps1.2.4.1.1 "><p id="p20981135135215"><a name="p20981135135215"></a><a name="p20981135135215"></a>afterAll</p>
575</td>
576<td class="cellrowborder" valign="top" width="68.88688868886888%" headers="mcps1.2.4.1.2 "><p id="p39811935115217"><a name="p39811935115217"></a><a name="p39811935115217"></a>测试套级别的清理条件,在所有测试用例结束后执行且仅执行一次,支持一个参数:清理动作函数</p>
577</td>
578<td class="cellrowborder" valign="top" width="13.19131913191319%" headers="mcps1.2.4.1.3 "><p id="p998110354527"><a name="p998110354527"></a><a name="p998110354527"></a>可选</p>
579</td>
580</tr>
581<tr id="row1298116359526"><td class="cellrowborder" valign="top" width="17.92179217921792%" headers="mcps1.2.4.1.1 "><p id="p898112359526"><a name="p898112359526"></a><a name="p898112359526"></a>beforeEach</p>
582</td>
583<td class="cellrowborder" valign="top" width="68.88688868886888%" headers="mcps1.2.4.1.2 "><p id="p149811335175215"><a name="p149811335175215"></a><a name="p149811335175215"></a>测试用例级别的预置条件,在每条测试用例开始前执行,执行次数与 it 定义的测试用例数一致,支持一个参数:预置动作函数</p>
584</td>
585<td class="cellrowborder" valign="top" width="13.19131913191319%" headers="mcps1.2.4.1.3 "><p id="p13981133585212"><a name="p13981133585212"></a><a name="p13981133585212"></a>可选</p>
586</td>
587</tr>
588<tr id="row6982435115219"><td class="cellrowborder" valign="top" width="17.92179217921792%" headers="mcps1.2.4.1.1 "><p id="p19982133517525"><a name="p19982133517525"></a><a name="p19982133517525"></a>afterEach</p>
589</td>
590<td class="cellrowborder" valign="top" width="68.88688868886888%" headers="mcps1.2.4.1.2 "><p id="p1398213575219"><a name="p1398213575219"></a><a name="p1398213575219"></a>测试用例级别的清理条件,在每条测试用例结束后执行,执行次数与 it 定义的测试用例数一致,支持一个参数:清理动作函数</p>
591</td>
592<td class="cellrowborder" valign="top" width="13.19131913191319%" headers="mcps1.2.4.1.3 "><p id="p159821535195219"><a name="p159821535195219"></a><a name="p159821535195219"></a>可选</p>
593</td>
594</tr>
595<tr id="row16982143513521"><td class="cellrowborder" valign="top" width="17.92179217921792%" headers="mcps1.2.4.1.1 "><p id="p598203510527"><a name="p598203510527"></a><a name="p598203510527"></a>describe</p>
596</td>
597<td class="cellrowborder" valign="top" width="68.88688868886888%" headers="mcps1.2.4.1.2 "><p id="p5982123595215"><a name="p5982123595215"></a><a name="p5982123595215"></a>定义一个测试套,支持两个参数:测试套名称和测试套函数; describe 支持嵌套,每个 describe 内均可以定义 beforeAll 、beforeEach 、afterEach 和 afterAll</p>
598</td>
599<td class="cellrowborder" valign="top" width="13.19131913191319%" headers="mcps1.2.4.1.3 "><p id="p898217352527"><a name="p898217352527"></a><a name="p898217352527"></a>必选</p>
600</td>
601</tr>
602<tr id="row6982113518526"><td class="cellrowborder" valign="top" width="17.92179217921792%" headers="mcps1.2.4.1.1 "><p id="p17982123510526"><a name="p17982123510526"></a><a name="p17982123510526"></a>it</p>
603</td>
604<td class="cellrowborder" valign="top" width="68.88688868886888%" headers="mcps1.2.4.1.2 "><p id="p598211352522"><a name="p598211352522"></a><a name="p598211352522"></a>定义一条测试用例,支持三个参数:用例名称,过滤参数和用例函数</p>
605<p id="p5205769588"><a name="p5205769588"></a><a name="p5205769588"></a>备注:</p>
606<p id="p6965058101"><a name="p6965058101"></a><a name="p6965058101"></a>过滤参数:过滤参数为一个 32 位的 Int 类型参数,0 位 置1表示不筛选、默认执行;0-10 位 置1表示<strong id="b9169154410212"><a name="b9169154410212"></a><a name="b9169154410212"></a>测试用例类型</strong>;16-18 位 置1表示<strong id="b1427947428"><a name="b1427947428"></a><a name="b1427947428"></a>测试用例规模</strong>;24-28 位 置1表示<strong id="b289818491213"><a name="b289818491213"></a><a name="b289818491213"></a>测试层级</strong>。</p>
607<p id="p7965165151011"><a name="p7965165151011"></a><a name="p7965165151011"></a><strong id="b69449534215"><a name="b69449534215"></a><a name="b69449534215"></a>测试用例类型</strong>。置位0-10分别表示:FUNCTION 方法类测试、PERFORMANCE 性能类测试、POWER 功耗类测试、RELIABILITY 可靠性测试、SECURITY 安全合规测试、GLOBAL 整体性测试、COMPATIBILITY 兼容性测试、USER 用户测试、STANDARD 标准测试、SAFETY 安全特性测试,RESILIENCE 压力测试。</p>
608<p id="p199651555102"><a name="p199651555102"></a><a name="p199651555102"></a><strong id="b10114125712211"><a name="b10114125712211"></a><a name="b10114125712211"></a>测试用例规模</strong>。置位16-18分别表示:SMALL 小型测试、MEDIUM 中型测试、LARGE 大型测试。</p>
609<p id="p296545151020"><a name="p296545151020"></a><a name="p296545151020"></a><strong id="b167975581223"><a name="b167975581223"></a><a name="b167975581223"></a>测试层级</strong>。置位24-28分别表示:LEVEL0-0 级测试、LEVEL1-1 级测试、LEVEL2-2 级测试、LEVEL3-3 级测试、LEVEL4-4 级测试。</p>
610</td>
611<td class="cellrowborder" valign="top" width="13.19131913191319%" headers="mcps1.2.4.1.3 "><p id="p17601752115716"><a name="p17601752115716"></a><a name="p17601752115716"></a>必选</p>
612</td>
613</tr>
614</tbody>
615</table>
616
617用例编写语法采用 jasmine 的标准语法,格式支持ES6格式。
618
619**以FA 模式为例:**
620
6211.  规范用例目录:测试用例存储到 src/main/js/test目录。
622
623    ```
624    ├── BUILD.gn
625    ├── Test.json                    # 资源依赖hap不需要Test.json文件
626    ├── signature
627    │ └──openharmony_sx.p7b          # 签名工具
628    └──src
629    │ └──main
630    │ │ └──js
631    │ │ │ └──MainAbility
632    │ │ │ │ └──app.js
633    │ │ │ │ └──pages
634    │ │ │ │ │ └──index
635    │ │ │ │ │ │ └──index.js
636    │ │ │ └──test                   # 测试代码存放目录
637    │ │ │ │ │ └──List.test.js
638    │ │ │ │ │ └──Ability.test.js
639    │ │ │ └──TestAbility            # 测试框架入口模板文件,添加后无需修改
640    │ │ │ │ └──app.js
641    │ │ │ │ └──pages
642    │ │ │ │ │ └──index
643    │ │ │ │ │ │ └──index.js
644    │ │ │ └──TestRunner             # 测试框架入口模板文件,添加后无需修改
645    │ │ │ │ └──OpenHarmonyTestRunner.js
646    │ └── resources                 # hap资源存放目录
647    │ └── config.json               # hap配置文件
648    ```
649
6502.  OpenHarmonyTestRunner.js 示例
651
652    ```
653    //加载js 测试框架
654    import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
655
656    ...
657
658     export default {
659        ...
660        onRun() {
661            console.log('OpenHarmonyTestRunner onRun run')
662            var abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments()
663            var abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
664
665            var testAbilityName = abilityDelegatorArguments.parameters['-p'] + '.MainAbility'
666
667            var cmd = 'aa start -d 0 -a ' + testAbilityName + ' -b ' + abilityDelegatorArguments.bundleName
668            ...
669        }
670    };
671    ```
672
6733.  index.js示例
674
675    ```
676    export default {
677        ...
678        onShow() {
679            console.info('onShow finish!')
680        },
681        ...
682    }
683    ```
684
6854.  app.js示例
686
687    ```
688    //加载测试用例
689    import { Hypium } from '@ohos/hypium'
690    import testsuite from '../test/List.test'
691    export default {
692        onCreate() {
693            console.info('TestApplication onCreate');
694            var abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
695            var abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments()
696            console.info('start run testcase!!!')
697            Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite)
698        },
699        ...
700    };
701    ```
702
7035.  单元测试用例示例
704
705    ```
706    // Example1: 使用HJSUnit进行单元测试
707    describe('appInfoTest', function () {
708        it('app_info_test_001', 0, function () {
709            var info = app.getInfo()
710            expect(info.versionName).assertEqual('1.0')
711            expect(info.versionCode).assertEqual('3')
712        })
713    })
714    ```
715
716
717FA_JS 模式测试模块下用例配置文件(BUILD.gn)样例:
718
719```
720import("//test/xts/tools/build/suite.gni")
721
722ohos_js_hap_suite("ActsDemoTest") {
723  hap_profile = "./src/main/config.json"
724  deps = [
725    ":hjs_demo_js_assets",
726    ":hjs_demo_resources",
727  ]
728  certificate_profile = "./signature/openharmony_sx.p7b"    //签名文件
729  hap_name = "ActsDemoTest"                                 //测试套件,以Acts开头,以Test结尾,采用驼峰式命名
730  part_name = "..."                                         //部件
731  subsystem_name = "..."                                    //子系统
732}
733ohos_js_assets("hjs_demo_js_assets") {
734  js2abc = true
735  hap_profile = "./src/main/config.json"
736  source_dir = "./src/main/js"
737}
738ohos_resources("hjs_demo_resources") {
739  sources = [ "./src/main/resources" ]
740  hap_profile = "./src/main/config.json"
741}
742```
743
744FA_TS 模式测试模块下用例配置文件(BUILD.gn)样例:
745
746```
747import("//test/xts/tools/build/suite.gni")
748
749ohos_js_hap_suite("ActsDemoTest") {
750  hap_profile = "./src/main/config.json"
751  deps = [
752    ":ace_demo_ets_assets",
753    ":ace_demo_ets_resources",
754    ":ace_demo_ets_test_assets",
755  ]
756  ets2abc = true
757  certificate_profile = "./signature/openharmony_sx.p7b"   //签名文件
758  hap_name = "ActsDemoTest"                                //测试套件,以Acts开头,以Test结尾,采用驼峰式命名
759  part_name = "..."                                        //部件
760  subsystem_name = "..."                                   //子系统
761}
762ohos_js_assets("ace_demo_ets_assets") {
763  source_dir = "./src/main/ets/MainAbility"
764}
765ohos_js_assets("ace_demo_ets_test_assets") {
766  source_dir = "./src/main/ets/TestAbility"
767}
768ohos_resources("ace_demo_ets_resources") {
769  sources = [ "./src/main/resources" ]
770  hap_profile = "./src/main/config.json"
771}
772```
773
774FA_JS 模式适配指导请参考
775
776​                  [JS工程目录结构(FA模型)](https://gitee.com/openharmony/xts_acts/wikis/XTS_%E7%99%BE%E7%A7%91%E6%8C%87%E5%AF%BC/JS%E5%B7%A5%E7%A8%8B%E7%9B%AE%E5%BD%95%E7%BB%93%E6%9E%84%EF%BC%88FA%E6%A8%A1%E5%9E%8B%EF%BC%89)
777
778FA_TS 模式适配指导请参考
779
780​                  [eTS工程目录结构(FA模型)](https://gitee.com/openharmony/xts_acts/wikis/XTS_%E7%99%BE%E7%A7%91%E6%8C%87%E5%AF%BC/eTS%E5%B7%A5%E7%A8%8B%E7%9B%AE%E5%BD%95%E7%BB%93%E6%9E%84%EF%BC%88FA%E6%A8%A1%E5%9E%8B%EF%BC%89)
781
782**以Stage 模式为例:**
783
7841. 规范用例目录:测试用例存储到 src/main/js/test目录。
785
786   ```
787   ├── BUILD.gn                     # 配置文件
788   ├── Test.json                    # 资源依赖hap不需要Test.json文件
789   ├── signature
790   │ └──openharmony_sx.p7b          # 签名工具
791   ├── AppScope
792   │ └──resource
793   │ └──app.json
794   ├── entry
795   │ └──src
796   │ │ └──main
797   │ │ │ └──ets
798   │ │ │ │ └──test                   # 测试代码存放目录
799   │ │ │ │ │ └──List.test.ets
800   │ │ │ │ │ └──Ability.test.ets
801   │ │ │ │ └──MainAbility
802   │ │ │ │ │ └──MainAbility.ts
803   │ │ │ │ │ └──pages
804   │ │ │ │ │ │ └──index
805   │ │ │ │ │ │ │ └──index.ets
806   │ │ │ │ └──TestAbility
807   │ │ │ │ │ └──TestAbility.ts       # 测试用例启动入口 ability
808   │ │ │ │ │ └──pages
809   │ │ │ │ │ │ └──index.ets
810   │ │ │ │ └──Application
811   │ │ │ │ │ └──AbilityStage.ts
812   │ │ │ │ └──TestRunner             # 测试框架入口模板文件,添加后无需修改
813   │ │ │ │ │ └──OpenHarmonyTestRunner.js
814   │ │ └── resources                 # hap资源存放目录
815   │ │ └── module.json               # hap配置文件
816   ```
817
8182. OpenHarmonyTestRunner.ts 示例
819
820   【注】在TestRunner目录下的 OpenHarmonyTestRunner.ts 文件中的 async onRun() 方法下存在拉起测试套入口xxxAbility的cmd 命令:
821
822   例如:
823
824   var cmd = 'aa start -d 0 -a TestAbility' + ' -b ' + abilityDelegatorArguments.bundleName
825
826   需与module.json中 "abilities" 下的 "name" 字段保持一致,保证拉起的是我们需要的测试入口。
827
828   ```
829   import TestRunner from '@ohos.application.testRunner'
830   import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
831
832   ...
833
834   export default class OpenHarmonyTestRunner implements TestRunner {
835       ...
836       async onRun() {
837           console.log('OpenHarmonyTestRunner onRun run')
838           abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments()
839           abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
840           var testAbilityName = abilityDelegatorArguments.bundleName + '.TestAbility'
841           let lMonitor = {
842               abilityName: testAbilityName,
843               onAbilityCreate: onAbilityCreateCallback,
844           };
845           abilityDelegator.addAbilityMonitor(lMonitor, addAbilityMonitorCallback)
846           var cmd = 'aa start -d 0 -a TestAbility' + ' -b ' + abilityDelegatorArguments.bundleName
847           ...
848       }
849   };
850   ```
851
8523. index.ets示例
853
854   ```
855   import router from '@ohos.router';
856
857   @Entry
858   @Component
859   struct Index {
860
861     aboutToAppear(){
862       console.info("start run testcase!!!!")
863     }
864
865     build() {
866       ...
867     }
868   }
869   ```
870
8714. app.js示例
872
873   ```
874   //加载测试用例
875   import Ability from '@ohos.app.ability.UIAbility'
876   import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
877   import { Hypium } from '@ohos/hypium'
878   import testsuite from '../test/List.test'
879
880   export default class TestAbility extends Ability {
881       onCreate(want, launchParam) {
882           console.log('TestAbility onCreate')
883           var abilityDelegator: any
884           abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
885           var abilityDelegatorArguments: any
886           abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments()
887           console.info('start run testcase!!!')
888           Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite)
889       }
890       ...
891   };
892   ```
893
894Stage 模式测试模块下用例配置文件(BUILD.gn)样例:
895
896```
897import("//test/xts/tools/build/suite.gni")
898
899ohos_js_hap_suite("ActsDemoTest") {
900  hap_profile = "/src/main/module.json"
901  js_build_mode = "debug"
902  deps = [
903    ":edm_js_assets",
904    ":edm_resources",
905  ]
906  ets2abc = true
907  certificate_profile = "signature/openharmony_sx.p7b"     //签名文件
908  hap_name = "ActsDemoTest"                                //测试套件,以Acts开头,以Test结尾,采用驼峰式命名
909  subsystem_name = "customization"                         //子系统
910  part_name = "enterprise_device_management"               //部件
911}
912
913ohos_app_scope("edm_app_profile") {
914  app_profile = "AppScope/app.json"
915  sources = [ "AppScope/resources" ]
916}
917
918ohos_js_assets("edm_js_assets") {
919  source_dir = "/src/main/ets"
920}
921
922ohos_resources("edm_resources") {
923  sources = [ "/src/main/resources" ]
924  deps = [ ":edm_app_profile" ]
925  hap_profile = "/src/main/module.json"
926}
927```
928
929Stage 模式适配指导请参考
930
931​                          [eTS工程目录结构(Stage模型)](https://gitee.com/openharmony/xts_acts/wikis/XTS_%E7%99%BE%E7%A7%91%E6%8C%87%E5%AF%BC/eTS%E5%B7%A5%E7%A8%8B%E7%9B%AE%E5%BD%95%E7%BB%93%E6%9E%84%EF%BC%88Stage%E6%A8%A1%E5%9E%8B%EF%BC%89)
932
933### JS语言用例编译打包指导(适用于标准系统)<a name="section445519106559"></a>
934
935hap包编译请参考 [标准系统 JS用例源码编译Hap包指导](https://gitee.com/openharmony/xts_acts/wikis/%E6%A0%87%E5%87%86%E7%B3%BB%E7%BB%9F%20JS%E7%94%A8%E4%BE%8B%E6%BA%90%E7%A0%81%E7%BC%96%E8%AF%91Hap%E5%8C%85%E6%8C%87%E5%AF%BC%20?sort_id=4427112)936
937### 全量编译指导(适用于标准系统)<a name="section159801435165220"></a>
938
9391.  全量编译
940    test/xts/acts目录下执行编译命令:
941
942    ```
943    ./build.sh product_name=rk3568 system_size=standard
944    ```
945
9462.  单个子系统编译
947
948    test/xts/acts目录下执行编译命令:
949
950    ```
951    ./build.sh product_name=rk3568 system_size=standard target_subsystem=××××
952    ```
953
9543.  单模块编译
955
956    test/xts/acts目录下执行编译命令:
957
958    ```./build.sh suite=acts system_size=standard target_subsystem=××××
959    ./build.sh product_name=rk3568 system_size=standard suite=xxx
960    suite 后面添加的是BUILD.gn 中ohos_js_hap_suite模板的命名
961    ```
962
963    测试用例输出目录:out/rk3568/suites/acts/testcases
964
965    测试框架&用例整体输出目录:out/rk3568/suites/acts(编译用例时会同步编译测试套执行框架)
966
967### 全量用例执行指导(适用于小型系统、标准系统)<a name="section159801435165220"></a>
968
969搭建测试环境Windows工作台下安装python3.7及以上版本,确保工作台和测试设备正常连接。
970
971**注:高版本python不带 easy_install,可以安装低于 52.0.0 的 setuptools,解决该问题。**
972
973```
974pip install setuptools==50.0.0
975```
976
977测试执行目录(对应编译生成的out/release/suites/acts目录)
978
979    ├── testcase                       # 测试套文件存放目录
980    │ └──xxx.hap                       # 测试套可执行hap文件
981    │ └──xxx.json                      # 测试套对应执行配置文件
982    ├── tools                          # 测试框架工具目录
983    ├── run.bat                        # window平台测试套启动执行文件
984    ├── report                         # 测试报告生成目录
985
986用例执行
9871.  在Windows工作台上,找到从Linux服务器上拷贝下来的测试套件用例目录,在Windows命令窗口进入对应目录,直接执行acts\run.bat988
9892.  界面启动后,输入用例执行指令。
990
991    全量执行:```run acts ```
992
993    模块执行(具体模块可以查看\acts\testcases\):```run –l ActsSamgrTest ```
994
995    单包执行(具体模块可以查看\acts\testcases\):(适用于OH驱动)
996
997    ```
998    run -l uitestActs -ta class:UiTestCase#testChecked
999
1000    uitestActs: 测试hap
1001    UiTestCase: testsuite
1002    testChecked: testcase
1003    ```
1004
1005
10063.  查看测试报告。
1007    进入acts\reports\,获取当前的执行记录,打开“summary_report.html”可以获取到测试报告。
1008
1009## 相关仓<a name="section1371113476307"></a>
1010
1011**xts\_acts**
1012
1013[xts\_tools](https://gitee.com/openharmony/xts_tools)
1014
1015