adb shell monkey -p 包名1 -v -v -v 10
下面就是我贴出的详细 LOG:(表情代替注释符号,以免跟日志搞混)
伪随机种子数与事件总数
:Monkey: seed=1519697645236 count=10
允许测试包
:AllowPackage: 包名1
Category 包含的 LAUNCHER
:IncludeCategory: android.intent.category.LAUNCHER
Category 包含的 MONKEY
:IncludeCategory: android.intent.category.MONKEY
查询允许包的 activity 结果列表
// Selecting main activities from category android.intent.category.LAUNCHER
这些都不是指定包的 activity
// - NOT USING main activity com.android.browser.BrowserActivity (from package com.android.browser)
// - NOT USING main activity com.android.calendar.homepage.AllInOneActivity (from package com.android.calendar)
// - NOT USING main activity com.android.camera.Camera (from package com.android.camera)
.... 中间忽略,从这也可以看出你手机上都安装了哪些应用
这个就是我们指定的包的 activity
// + Using main activity 包名1.ui.portal.WelcomeActivity (from package 包名1)
// Selecting main activities from category android.intent.category.MONKEY
种子为 1519697645236
// Seeded: 1519697645236
事件百分比
// Event percentages:
// 0: 15.0%
// 1: 10.0%
// 2: 2.0%
// 3: 15.0%
// 4: -0.0%
// 5: -0.0%
// 6: 25.0%
// 7: 15.0%
// 8: 2.0%
// 9: 2.0%
// 10: 1.0%
// 11: 13.0%
表示跳转到 com.crazyhornets.MyHokageAndroidZSY 包中的 com.crazyhornets.MyHokage.MyHokageActivity 里
:Switch:
#Intent;action=android.intent.action.MAIN;category=android.intent.category.LAUNCHER;launchFlags=0x10200000;component=cn.yaomaitong.app.daily/cn.yaomaitong.app.ui.portal.WelcomeActivity;end
允许此 Intent 跳转
// Allowing start of Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=cn.yaomaitong.app.daily/cn.yaomaitong.app.ui.portal.WelcomeActivity } in package cn.yaomaitong.app.daily
// Allowing start of Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=cn.yaomaitong.app.daily/cn.yaomaitong.app.ui.portal.WelcomeActivity } in package cn.yaomaitong.app.daily
以下就是事件间的延迟和发送的各种事件
--pct-nav 事件
Sleeping for 0 milliseconds
:Sending Key (ACTION_DOWN): 82 // KEYCODE_MENU
:Sending Key (ACTION_UP): 82 // KEYCODE_MENU
Sleeping for 0 milliseconds
:Switch:
#Intent;action=android.intent.action.MAIN;category=android.intent.category.LAUNCHER;launchFlags=0x10200000;component=cn.yaomaitong.app.daily/cn.yaomaitong.app.ui.portal.WelcomeActivity;end
// Allowing start of Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=cn.yaomaitong.app.daily/cn.yaomaitong.app.ui.portal.WelcomeActivity } in package cn.yaomaitong.app.daily
// Allowing start of Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=cn.yaomaitong.app.daily/cn.yaomaitong.app.ui.portal.WelcomeActivity } in package cn.yaomaitong.app.daily
--pct-touch 事件
Sleeping for 0 milliseconds
:Sending Touch (ACTION_DOWN): 0:(532.0,1392.0)
:Sending Touch (ACTION_UP): 0:(542.04724,1391.5958)
--pct-motion 事件
Sleeping for 0 milliseconds
:Sending Touch (ACTION_DOWN): 0:(838.0,113.0)
:Sending Touch (ACTION_UP): 0:(852.82526,101.77225)
--pct-trackball 事件
Sleeping for 0 milliseconds
:Sending Trackball (ACTION_MOVE): 0:(1.0,4.0)
:Sending Trackball (ACTION_MOVE): 0:(-5.0,-3.0)
--pct-rotation 屏幕旋转百分比 ####隐藏事件
: Sending rotation degree=0, persist=true
: Sending rotation degree=1, persist=false:
: Sending rotation degree=2, persist=true
: Sending rotation degree=3, persist=false
注入事件 10
Events injected: 10
发送屏幕翻转 度=0,存留=假
:Sending rotation degree=0, persist=false
丢弃:键=0,指针=0,轨迹球=0,键盘轻弹=0,屏幕翻转=0
:Dropped: keys=0 pointers=0 trackballs=0 flips=0 rotations=0
网络状态:占用时间=42ms(手机 0ms,wifi0ms,未连接 42ms)
## Network stats: elapsed time=42ms (0ms mobile, 0ms wifi, 42ms not connected)
Monkey 测试完成
// Monkey finished
// CRASH: cn.包名1 (pid 3165)
// Short Msg: java.lang.IllegalStateException
// Long Msg: java.lang.IllegalStateException: Fragment SingleChatFragment{366281} not attached to Activity
// Build Label: Xiaomi/sagit/sagit:7.1.1/NMF26X/V9.2.4.0.NCACNEK:user/release-keys
// Build Changelist: V9.2.4.0.NCACNEK
// Build Time: 1516183841000
// java.lang.IllegalStateException: Fragment SingleChatFragment{366281} not attached to Activity
// at android.support.v4.app.Fragment.getResources(Fragment.java:646)
// at cn.yaomaitong.app.ui.message.fragment.SingleChatFragment$13$1.run(SingleChatFragment.java:586)
// at android.os.Handler.handleCallback(Handler.java:754)
// at android.os.Handler.dispatchMessage(Handler.java:95)
// at android.os.Looper.loop(Looper.java:163)
// at android.app.ActivityThread.main(ActivityThread.java:6365)
// at java.lang.reflect.Method.invoke(Native Method)
// at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:901)
// at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:791)
--ignore-crashes
--ignore-crashes
参数,就先浏览日志中Events injected: 值
,查看当前已执行的次数,就知道有无 bug