猴子测试会不会偶尔进入设置点击重启按钮重启设备?
Will Monkey test occasionally enter settings and click the restart button to restart device?
在 android 设备上进行 Monkey 测试时,我发送
adb shell monkey --ignore-security-exceptions --ignore-crashes --ignore-timeouts --ignore-native-crashes --throttle 200 -s 222 -v -v -v 125000 > c:\all_monkey.txt
然后 Monkey 会向设备发送很多随机事件,我可以看到很多滑动屏幕或点击按钮。 Monkey会不会偶尔进入设置点击重启按钮重启设备?因为我发现当 运行 一段时间后,设备会自行重启。我可以避免 Monkey 测试自己点击重启按钮吗?谢谢。
是的,您可以使用来自 ActivityManager
:
的检查来包装您的重启函数
if(!ActivityManager.isUserAMonkey()){
//your code
}
Returns "true" if the user interface is currently being messed with by a monkey.
编辑:因为我第一次误解了这个问题,这里有一些可能有用的答案:
-p flag
adb shell monkey -p your.application.id.here //to restrict mokey to your application
--pct-syskeys
By setting the -pct-sysevents to zero. However the catch here is the order of events. - kopos
您可以简单地告诉 Monkey () 搞砸由包名称指定的特定应用程序。 (例如,只允许猴子搞砸您的应用程序!)
为此,请将 -p <allowed-package-name>
添加到您的命令中。
Docs 说:
If you specify one or more packages this way, the Monkey will only allow the system to visit activities within those packages. If your application requires access to activities in other packages (e.g. to select a contact) you'll need to specify those packages as well. If you don't specify any packages, the Monkey will allow the system to launch activities in all packages. To specify multiple packages, use the -p option multiple times — one -p option per package.
在 android 设备上进行 Monkey 测试时,我发送
adb shell monkey --ignore-security-exceptions --ignore-crashes --ignore-timeouts --ignore-native-crashes --throttle 200 -s 222 -v -v -v 125000 > c:\all_monkey.txt
然后 Monkey 会向设备发送很多随机事件,我可以看到很多滑动屏幕或点击按钮。 Monkey会不会偶尔进入设置点击重启按钮重启设备?因为我发现当 运行 一段时间后,设备会自行重启。我可以避免 Monkey 测试自己点击重启按钮吗?谢谢。
是的,您可以使用来自 ActivityManager
:
if(!ActivityManager.isUserAMonkey()){
//your code
}
Returns "true" if the user interface is currently being messed with by a monkey.
编辑:因为我第一次误解了这个问题,这里有一些可能有用的答案:
-p flag
adb shell monkey -p your.application.id.here //to restrict mokey to your application
--pct-syskeys
By setting the -pct-sysevents to zero. However the catch here is the order of events. - kopos
您可以简单地告诉 Monkey () 搞砸由包名称指定的特定应用程序。 (例如,只允许猴子搞砸您的应用程序!)
为此,请将 -p <allowed-package-name>
添加到您的命令中。
Docs 说:
If you specify one or more packages this way, the Monkey will only allow the system to visit activities within those packages. If your application requires access to activities in other packages (e.g. to select a contact) you'll need to specify those packages as well. If you don't specify any packages, the Monkey will allow the system to launch activities in all packages. To specify multiple packages, use the -p option multiple times — one -p option per package.