1.新建bat文件
2.输入monkey命令,完整命令如下:
adb wait-for-device
adb shell sleep 3
adb shell "monkey -p com.cmcc.poc.app --ignore-crashes --ignore-timeouts --kill-process-after-error --ignore-security-exceptions -v --throttle 300 1000 2>/sdcard/monkeyerror.txt 1>/sdcard/monkeyinfo.txt "
pause
说明:
adb shell "monkey -p com.cmcc.poc.app --ignore-crashes --ignore-timeouts --kill-process-after-error --ignore-security-exceptions -v -s 1101 --throttle 300 1000 2>/sdcard/monkeyerror.txt
--p + 包名,测试的APP包名。
使用adb shell dumpsys activity activities | findstr -i run 或者
adb shell dumpsys activity | findstr "mResume" 找到包名。
后面几个代表忽略崩溃、超时、错误、安全测试,-s 代表执行的ID,-v代表日志级别, --throttle 延迟300ms,执行一千次
2>/sdcard/monkeyerror.txt:这个部分是将标准错误输出重定向到/sdcard/monkeyerror.txt文件中。
任何由Monkey测试产生的错误信息都会被写入到这个文件中。
1>/sdcard/monkeyinfo.txt:这个部分是将标准输出重定向到/sdcard/monkeyinfo.txt文件中。
这包括关于Monkey测试执行过程的详细信息和日志。
通过重定向输出到文件,你可以方便地查看和分析Monkey测试的结果和日志,以便进一步调试和分析应用程序的稳定性和性能