Currently, testing of C/C++ methods and system APIs is not supported.


You can also create a test case under the test directory and add the corresponding test class to the List.test.ets file.
You can run all test cases in a project directory (test), run test cases from a file (such as Index.test.ets), run all tests associated with a test suite (describe), and run a specific test method (it). The test entries are as follows:
|
|
Directory entry | Test file entry |
|
|
Test suite entry | Method entry |
The following uses a test file as an example. In the project directory, right-click the target file and choose Run 'test file name' from the shortcut menu.

on the right.
View the test result after the test is complete.

Compared with the running mode, the debug mode provides breakpoint management. When a breakpoint is hit, you can perform single stepping, step-in, step-out, and stop-over operations as required. You can also view the thread stacks, variables, and expressions to quickly locate faults.
The following uses a test file as an example. After adding breakpoints, right-click the target file in the project directory and choose Debug 'Test file name' from the shortcut menu to perform a test task in debug mode.

When a breakpoint is hit, the Debug window is displayed. You can perform breakpoint management and basic debugging in this window. When a breakpoint is hit, you can view the variables and stack information of the current thread.

Right-click in the code editor window. The shortcut menu shows the functions specific to the debug mode, including Evaluate Expression, Run to Cursor, Force Run to Cursor, Add to Watches, and Add Inline Watch.

After the test is complete, view the test result on the console.

DevEco Studio provides the code coverage for local tests. Currently, only ArkTS projects are supported.
You can specify the local files or remote source code HAR packages to be included in or excluded from the coverage statistics. For details, see Filtering Files for Coverage Testing.
As with test cases without coverage, test cases with coverage can also be started from various entries. For example, to start a test case from a test file, use either of the following methods:

on the right.
After the test starts, the build process begins, and the Cover tab appears at the bottom. Once the build is complete, the Cover tab will automatically open. After the test task is finished, the path to the test report will be printed on the tab page.

Click the path link to open the report and view the code coverage details. For details about the coverage rate, see Viewing Coverage Reports.

On the Cover tab page, you can click the rerun button to re-execute the test case based on the previous settings.

By default, test cases can be run directly. To customize a test case task, perform the following steps:


hvigorw test -p module={moduleName} -p coverage={true | false} -p scope={suiteName}#{methodName} -p patch={patchPath}
Path of the test result file: <module-path>/.test/default/intermediates/test/coverage_data/test_result.txt