We use essential cookies for the website to function, as well as analytics cookies for analyzing and creating statistics of the website performance. To agree to the use of analytics cookies, click "Accept All". You can manage your preferences at any time by clicking "Cookie Settings" on the footer. More Information.

Only Essential Cookies
Accept All
GuidesSystemDebugging ToolsTest Kitwukong User Guide

wukong User Guide

Introduction

wukong is a built-in command line tool that implements application stability test capabilities such as random event injection, component injection, exception capture, report generation, and data traversal of abilities. This tool allows you to conduct stability tests on the system or applications by simulating user behavior. wukong provides three types of testing: random testing, special testing, and focus testing.

In random testing, test inputs are generated randomly. Available features include shell startup, whole application startup, multiple injection modes, random seeds setting, run log printing, and report generation.

In special testing, specific application components are tested. Available features include shell startup, sequential traversal and screenshot, sleep and wakeup test, recording and playback, run log printing, and report generation.

In focus testing, specific components are injected. Available features include shell startup, device application startup, multiple injection modes, random seed setting, focus component type setting, component injection times setting, run log printing, and report generation.

Principles

The following figure shows the wukong component architecture and the responsibilities of sub-modules.

  • Command line parsing: obtains and parses parameters using commands.
  • Operating environment management: initializes the overall operating environment of wukong using commands.
  • System API management: checks and obtains the specified mgr, and registers the callback function of Faultlogger for the controller and DFX.
  • Random event generation: generates a sequence of random numbers using a specified seed through a random function, and creates events based on this sequence.
  • Event injection: injects events of supported types to the system. This feature depends on the window, multimodal, and security subsystems.
  • Exception capture and processing and report generation: obtains exception information with the DFX subsystem during application running, record log, and generate reports.

Constraints

  1. The wukong tool is built in the system since API version 9.

  2. Before running any command, configure the hdc environment and enter the shell mode.

Functions and Commands

Expand
Command Description
-v/--version Obtains version information.
help Obtains help information.
appinfo Queries the bundle name and the name of the corresponding mainAbility of the app that can be started.
special Runs special testing.
exec Runs random testing.
focus Runs focus testing.

Running Commands

  • Open the shell.

    Collapse
    Word wrap
    Dark theme
    Copy code
    1. #If you are testing one device, run **hdc shell**.
    2. C:\Users>hdc shell
    3. $
    4. #If you are testing multiple devices, obtain the SNs first by running **hdc list targets**. Then, enter the shell.
    5. C:\Users>hdc list targets
    6. 15xxx424axxxx345209d94xxxx8fxx900
    7. C:\Users>hdc -t 15xxx424axxxx345209d94xxxx8fxx900 shell
    8. $
  • Obtain the bundle name and ability name of the application.

    Collapse
    Word wrap
    Dark theme
    Copy code
    1. $ wukong appinfo
    2. BundleName: com.ohos.adminprovisioning
    3. AbilityName: com.ohos.adminprovisioning.MainAbility
    4. BundleName: com.ohos.callui
    5. AbilityName: com.ohos.callui.MainAbility
  • View the help information.

    Collapse
    Word wrap
    Dark theme
    Copy code
    1. C:\Users>hdc shell
    2. $ wukong help #wukong help menu.
    3. usage: wukong <command> [<arguments>]
    4. These are common wukong command list:
    5. help wukong help information
    6. -v/--version wukong version
    7. exec run random test
    8. special run special test
    9. focus run focus test
    10. appinfo show all app information
    11. $ wukong exec -help #Help menu for wukong random testing.
    12. usage: wukong exec [<arguments>]
    13. These are wukong exec arguments list:
    14. -h, --help random test help
    15. -a, --appswitch appswitch event percent
    16. -b, --bundle the bundle name of allowlist
    17. -p, --prohibit the bundle name of blocklist
    18. -d, --page block page list
    19. -t, --touch touch event percent
    20. -c, --count test count
    21. -i, --interval interval
    22. -s, --seed random seed
    23. -m, --mouse mouse event percent
    24. -k, --keyboard keyboard event percent
    25. -H, --hardkey hardkey event percent
    26. -S, --swap swap event percent
    27. -T, --time test time
    28. -C, --component component event percent
    29. -r, --rotate rotate event percent
    30. -e, --allow ability the ability name of allowlist
    31. -E, --block ability the ability name of blocklist
    32. -Y, --blockCompId the id list of block component
    33. -y, --blockCompType the type list of block component
    34. -I, --screenshot get screenshot(only in random input)
    35. -B, --checkBWScreen black and white screen detection
    36. -U, --Uri set Uri pages
    37. -x, --Uri-type set Uri-type
    38. $ wukong special -help #Help menu for wukong special testing.
    39. usage: wukong special [<arguments>]
    40. These are wukong special arguments list:
    41. -h, --help special test help
    42. -t, --touch[x,y] touch event
    43. -c, --count total count of test
    44. -i, --interval interval
    45. -S, --swap[option] swap event
    46. option is -s| -e| -b
    47. -s, --start: the start point of swap
    48. -e, --end: the end point of swap
    49. -b, --bilateral: swap go and back
    50. -k, --spec_insomnia power on/off event
    51. -T, --time total time of test
    52. -C, --component component event
    53. -p, --screenshot get screenshot(only in component input)
    54. -r, --record record user operation
    55. -R, --replay replay user operation
    56. -u, --uitest uitest dumpLayout

Random Testing

Commands

Expand
Command Description Mandatory Description
-h,--help Obtains the help information about the test. No -
-c,--count Sets the number of execution times. This command conflicts with the -T command. Set either of them. No The default value is 10, in times.
-i,--interval Sets the test interval. No The default value is 1500, in millisecond.
-s,--seed Sets the random seed. No If the same random seed is set, the same random event sequence is generated.
-b,--bundle[bundlename, ......, bundlename] Sets allowed bundles for the test. This command conflicts with the -p command. No By default, all bundles on the device are allowed. Use commas (,) to separate bundle names.
-p,--prohibit[bundlename, ......, bundlename] Sets blocked bundles for the test. This command conflicts with the -b command. No By default, no bundle is blocked. Use commas (,) to separate bundle names.
-d,--page[page, ......, page] Sets blocked pages for the test. No By default, the pages/system pages are blocked. Use commas (,) to separate page names.
-a,--appswitch Sets the proportion of the random application startup event test. No The default value is 10%.
-t,--touch Sets the proportion of the random touch event test. No The default value is 10%.
-S,--swap Sets the proportion of the random swipe event test. No The default value is 3%.
-m,--mouse Sets the proportion of the random mouse event test. No The default value is 1%.
-k,--keyboard Sets the proportion of the random keyboard event test. No The default value is 2%.
-H,--hardkey Sets the proportion of the random hardkey test. No The default value is 2%.
-r,--rotate Sets the proportion of the random rotate event test. No The default value is 2%.
-C, --component Sets the proportion of random component test. No The default value is 70%.
-I, --screenshot Takes a screenshot for the component test. No -
-T,--time Sets the total test time. This command conflicts with the -c command. Set either of them. No The default value is 10, in minute.
-e, --allow ability Sets the ability that allows testing. No -
-E, --block ability Sets the ability that blocks testing. No -
-Y, --blockCompId Sets the blocked CompId. No -
-y, --blockCompType Sets the blocked CompType. No -
-B, --checkBWScreen Enables black and white screen check. No -
-U, -uri Sets the URI of the application startup page. No -
-x, -uriType Sets the URI type of the application startup page. No -

Special Testing

Commands

Expand
Command Description Mandatory Description
-h, --help Obtains the help information about the special testing. No -
-k, --spec_insomnia Powers on/off the special testing. No -
-c, --count Sets the number of test times. No The default value is 10, in times.
-i, --interval Sets the test interval. No The default value is 1500, in millisecond.
-S, --swap Sets a swipe event for the test. No -
-s, --start[x,y] Sets the coordinates of the start point of the swipe event. No The values of coordinates are positive.
-e, --end[x,y] Sets the coordinates of the end point of the swipe event. No The values of coordinates are positive.
-b, --bilateral Sets a back and forth swipe event. No By default, the back and forth swipe event is disabled.
-t, --touch[x,y] Sets a touch event for the test. No -
-T, --time Sets the total test time. No The default value is 10, in minute.
-C, --component Sets the sequential traversal test for components. No You need to set the name of the test application.
-r, --record Records user operation. No You need to specify the recording file.
-R, --replay Replays user operation. No You need to specify the playback file.
-p, --screenshot Takes a screenshot for the component test. No -

Focus Testing

Commands

Expand
Command Description Mandatory Description
-n,--numberfocus Sets the number of injections for each component. No Unit: times
-f, --focustypes Sets the types of component for the focus testing. No Use commas (,) to separate the types.
-h,--help Obtains the help information about the test. No -
-c,--count Sets the number of test times. This command conflicts with the -T command. Set either of them. No The default value is 10, in times.
-i,--interval Sets the test interval. No The default value is 1500, in millisecond.
-s,--seed Sets the random seed. No If the same random seed is set, the same random event sequence is generated.
-b,--bundle[bundlename, ......, bundlename] Sets allowed bundles for the test. This command conflicts with the -p command. No By default, all bundles on the device are allowed. Use commas (,) to separate bundle names.
-p,--prohibit[bundlename, ......, bundlename] Sets blocked bundles for the test. This command conflicts with the -b command. No By default, no bundle is blocked. Use commas (,) to separate bundle names.
-d,--page[page, ......, page] Sets blocked pages for the test. No By default, the pages/system pages are blocked. Use commas (,) to separate page names.
-a,--appswitch Sets the proportion of the random application startup event test. No The default value is 10%.
-t,--touch Sets the proportion of the random touch event test. No The default value is 10%.
-S,--swap Sets the proportion of the random swipe event test. No The default value is 3%.
-m,--mouse Sets the proportion of the random mouse event test. No The default value is 1%.
-k,--keyboard Sets the proportion of the random keyboard event test. No The default value is 2%.
-H,--hardkey Sets the proportion of the random hardkey test. No The default value is 2%.
-r,--rotate Sets the proportion of the random rotate event test. No The default value is 2%.
-C, --component Sets the proportion of random component test. No The default value is 70%.
-I, --screenshot Takes a screenshot for the component test. No -
-T,--time Sets the total test time. This command conflicts with the -c command. Set either of them. No The default value is 10, in minute.
-e, --allow ability Sets the ability that allows testing. No -
-E, --block ability Sets the ability that blocks testing. No -
-Y, --blockCompId Sets the blocked CompId. No -
-y, --blockCompType Sets the blocked CompType. No -
-B, --checkBWScreen Enables black and white screen check. No -

Viewing the Test Result

Test Result Output Path

After the test commands are executed, the test result is automatically generated. You can obtain the test result in the following directory:

  • For DevEco Studio versions earlier than September 22, 2022: /data/local/wukong/report/xxxxxxxx_xxxxxx/
  • For DevEco Studio versions later than September 22, 2022: /data/local/tmp/wukong/report/xxxxxxxx_xxxxxx/

Test Report Directories

Expand
Type Description
exception/ Stores exception files generated during the test.
screenshot/ Stores the screenshots of the test traversal.
wukong_report.csv Stores the test report summary.
wukong.log Indicates the test operation history.

Viewing Operation Logs

You can run the hdc command to obtain logs to the local host and view the operation history.

Collapse
Word wrap
Dark theme
Copy code
  1. # The path of the wukong.log file is as follows:
  2. /data/local/tmp/wukong/report/xxxxxxxx_xxxxxx/wukong.log
  3. # To view the directory of the wukong test report, run the following command:
  4. $ cd /data/local/tmp/wukong/report/20170805_170053
  5. $ ls
  6. data.js exception wukong.log wukong_report.csv
  7. # Open the shell and run hdc file recv to obtain wukong logs.
  8. C:\Users\xxx>hdc file recv /data/local/tmp/wukong/report/20170805_170053/wukong.log C:\Users\xxx\Desktop\log
  9. [I][2024-01-03 20:08:02] HdcFile::TransferSummary success
  10. FileTransfer finish, Size:76492, File count = 1, time:16ms rate:4780.75kB/s

FAQs

What should I do if "failed to connect to AAMS" is displayed?

Symptom

The error message "failed to connect to AAMS" is displayed.

Possible Cause

AAMS is occupied by Hypium or the UIViewer of DevEco Testing. AAMS can be connected to only one program at a time.

Solution

Stop the process that occupies AAMS or restart the device.

What should I do if "Errorcode:(4005)" is displayed?

Symptom

The error message "Errorcode:(4005)" is displayed.

Possible Cause

The size of the screen display area changes. As a result, the page information fails to be obtained.

Solution

This error does not affect the test process and does not need to be handled.

What should I do if "Errorcode:(4007)" is displayed?

Symptom

The error message "Errorcode:(4007)" is displayed.

Possible Cause

The size of the screen display area changes. As a result, the page information fails to be obtained.

Solution

This error does not affect the test process and does not need to be handled.

Search in Guides
Enter a keyword.