Test Cases for ohos-networkShare
Test Command Coverage
| Command Example |
Description |
Permission |
Prerequisites |
| ohos-networkShare help |
Show all available commands |
None |
None |
| ohos-networkShare help --format json |
Show commands in JSON format |
None |
None |
| ohos-networkShare help is-supported |
Show help for is-supported command |
None |
None |
| ohos-networkShare help is-supported --format json |
Show help for is-supported in JSON |
None |
None |
| ohos-networkShare help is-sharing |
Show help for is-sharing command |
None |
None |
| ohos-networkShare help is-sharing --format json |
Show help for is-sharing in JSON |
None |
None |
| ohos-networkShare help start |
Show help for start command |
None |
None |
| ohos-networkShare help start --format json |
Show help for start in JSON |
None |
None |
| ohos-networkShare help stop |
Show help for stop command |
None |
None |
| ohos-networkShare help stop --format json |
Show help for stop in JSON |
None |
None |
| ohos-networkShare is-supported |
Check if network sharing is supported |
ohos.permission.CONNECTIVITY_INTERNAL |
None |
| ohos-networkShare is-sharing |
Check current sharing status |
ohos.permission.CONNECTIVITY_INTERNAL |
None |
| ohos-networkShare start --type wifi |
Start WiFi sharing |
ohos.permission.CONNECTIVITY_INTERNAL |
None |
| ohos-networkShare start --type usb |
Start USB sharing |
ohos.permission.CONNECTIVITY_INTERNAL |
None |
| ohos-networkShare start --type bluetooth |
Start Bluetooth sharing |
ohos.permission.CONNECTIVITY_INTERNAL |
None |
| ohos-networkShare stop --type wifi |
Stop WiFi sharing |
ohos.permission.CONNECTIVITY_INTERNAL |
None |
| ohos-networkShare stop --type usb |
Stop USB sharing |
ohos.permission.CONNECTIVITY_INTERNAL |
None |
| ohos-networkShare stop --type bluetooth |
Stop Bluetooth sharing |
ohos.permission.CONNECTIVITY_INTERNAL |
None |
Expected Outputs
help command
ohos-networkShare <command> [args]
Commands:
help Show this help message
is-supported Check if network sharing is supported on the device
is-sharing Check if network sharing is currently active
start Start network sharing
stop Stop network sharing
Run 'ohos-networkShare <command> --help' for more information.
{
"command": "ohos-networkShare",
"commands": [
{"name": "help", "description": "Show this help message"},
{"name": "is-supported", "description": "Check if network sharing is supported on the device"},
{"name": "is-sharing", "description": "Check if network sharing is currently active"},
{"name": "start", "description": "Start network sharing"},
{"name": "stop", "description": "Stop network sharing"}
]
}
is-supported command
{"type":"result","status":"success","data":{"supported":true}}
{"type":"result","status":"success","data":{"supported":false}}
is-sharing command
{"type":"result","status":"success","data":{"sharing":true}}
{"type":"result","status":"success","data":{"sharing":false}}
start command
{"type":"result","status":"success","data":{"message":"Network sharing started successfully","type":"wifi"}}
{"type":"result","status":"success","data":{"message":"Network sharing started successfully","type":"usb"}}
{"type":"result","status":"success","data":{"message":"Network sharing started successfully","type":"bluetooth"}}
stop command
{"type":"result","status":"success","data":{"message":"Network sharing stopped successfully","type":"wifi"}}
{"type":"result","status":"success","data":{"message":"Network sharing stopped successfully","type":"usb"}}
{"type":"result","status":"success","data":{"message":"Network sharing stopped successfully","type":"bluetooth"}}
Error Cases
Missing parameter
{"type":"result","status":"failed","errCode":"ERR_MISSING_PARAM","errMsg":"Missing required parameter: sharing type","suggestion":"Valid types: wifi, usb, bluetooth. Example: ohos-networkShare start --type wifi"}
{"type":"result","status":"failed","errCode":"ERR_MISSING_PARAM","errMsg":"Missing required parameter: sharing type","suggestion":"Valid types: wifi, usb, bluetooth. Example: ohos-networkShare stop --type wifi"}
Invalid parameter
{"type":"result","status":"failed","errCode":"ERR_INVALID_PARAM","errMsg":"Invalid sharing type: invalid","suggestion":"Valid types: wifi, usb, bluetooth"}
{"type":"result","status":"failed","errCode":"ERR_INVALID_PARAM","errMsg":"Invalid sharing type: invalid","suggestion":"Valid types: wifi, usb, bluetooth"}
Permission denied
{"type":"result","status":"failed","errCode":"ERR_OPERATION_FAILED","errMsg":"Permission denied. Requires ohos.permission.CONNECTIVITY_INTERNAL","suggestion":"Ensure the device has network sharing capability and proper permissions."}
System caller check failed
{"type":"result","status":"failed","errCode":"ERR_OPERATION_FAILED","errMsg":"System caller only. This tool must be run by system processes.","suggestion":"Ensure proper permissions and that the sharing type is available on this device."}
Command Coverage Summary
| Command |
Parameters Tested |
Total Cases |
| help |
none, --format json, , --format json |
11 |
| is-supported |
none |
1 |
| is-sharing |
none |
1 |
| start |
wifi, usb, bluetooth |
3 |
| stop |
wifi, usb, bluetooth |
3 |
Total Test Cases: 19
Coverage: 100% of all commands and all parameter combinations