Android monkey 基礎入門介紹
目錄
一、為什麼要用Monkey 測試?
簡單在說就是象猴子一樣亂點,為了測試軟體的穩定性,健壯性。號稱最快速有效的方法。有時候執行相同系列的測試,即使是複雜的測試,但是以相同的順序和路徑,即使一遍又一遍地執行也很少機會能發現記憶體和資源使用的bug。而此時猴子就比人更有效了。
二、簡介
Monkey是一個命令列工具 ,可以執行在模擬器裡或實際裝置中。它向系統傳送偽隨機的使用者事件流,實現對正在開發的應用程式進行壓力測試。Monkey包括許多選項,它們大致分為四大類:
· 基本配置 選項,如設定嘗試的事件數量。
· 執行約束選項,如設定只對單獨的一個包進行測試。
· 事件型別和頻率。
· 除錯選項。
在Monkey執行的時候,它生成事件,並把它們發給系統。同時,Monkey還對測試中的系統進行監測,對下列三種情況進行特殊處理:
· 如果限定了Monkey執行在一個或幾個特定的包上,那麼它會監測試圖轉到其它包的操作,並對其進行阻止。
· 如果應用程式崩潰或接收到任何失控異常 ,Monkey將停止並報錯。
· 如果應用程式產生了應用程式不響應(application not responding)的錯誤,Monkey將會停止並報錯。
按照選定的不同級別的反饋資訊,在Monkey中還可以看到其執行過程報告和生成的事件。
三、怎麼用的?
1、首先用一個最簡單的例子分析:
//p引數: 表示指定測試的程式
//v引數: 表示檢視monkey生成的一些詳細的隨機的事件名
//數字
100
: 表示測試事件數為
100
monkey -p com.example.android.apis -v -v -v
100
結果如下:
:Monkey: seed=
0
count=
100
:AllowPackage: com.example.android.apis
:IncludeCategory: android.intent.category.LAUNCHER
:IncludeCategory: android.intent.category.MONKEY
//各種事件所佔的比例。
//各數字分別表示:
[--pct-touch PERCENT]
[--pct-motion PERCENT]
[--pct-trackball PERCENT]
[--pct-syskeys PERCENT]
[--pct-nav PERCENT]
[--pct-majornav PERCENT]
[--pct-appswitch PERCENT]
[--pct-flip PERCENT]
[--pct-anyevent PERCENT]
// Event percentages:
// 0: 15.0%
// 1: 10.0%
// 2: 15.0%
// 3: 25.0%
// 4: 15.0%
// 5: 2.0%
// 6: 2.0%
// 7: 1.0%
// 8: 15.0%
:Switch:
//表示跳轉到com.example.android.apis 裡面的ApiDemos這一個Activity裡。
#Intent;action=android.intent.action.MAIN;category=android.intent.category.LAUNCHER;launchFlags=
0x10000000
;component=com.example.android.apis/.ApiDemos;end
//允許此Intent跳轉,
// Allowing start of Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=com.example.android.apis/.ApiDemos } in package com.example.android.apis
//傳送的一些動作,如點選按下,點選放開,移動。
:Sending Pointer ACTION_MOVE x=-
4.0
y=
2.0
:Sending Pointer ACTION_UP x=
0.0
y=
0.0
:Sending Pointer ACTION_DOWN x=
207.0
y=
282.0
:Sending Pointer ACTION_UP x=
189.0
y=
289.0
:Sending Pointer ACTION_DOWN x=
95.0
y=
259.0
:Sending Pointer ACTION_UP x=
95.0
y=
259.0
:Sending Pointer ACTION_DOWN x=
295.0
y=
223.0
:Sending Pointer ACTION_UP x=
290.0
y=
213.0
:Sending Pointer ACTION_MOVE x=-
5.0
y=
3.0
:Sending Pointer ACTION_MOVE x=
0.0
y=-
5.0
//拒絕此跳轉,因為它是跳轉到非它自己的包的Activity,本測試中是指寫測試它程式所在的包,此跳轉是跳出本程式,進入到桌面。
// Rejecting start of Intent { act=android.intent.action.MAIN cat=[android.intent.category.HOME] cmp=com.android.launcher/.Launcher } in package com.android.launcher
//繼續傳送動作。
:Sending Pointer ACTION_DOWN x=
74.0
y=
201.0
:Sending Pointer ACTION_UP x=
74.0
y=
201.0
:Sending Pointer ACTION_MOVE x=
3.0
y=-
2.0
:Sending Pointer ACTION_UP x=
0.0
y=
0.0
:Sending Pointer ACTION_MOVE x=-
4.0
y=
2.0
Events injected:
100
//丟棄的,鍵=
0
,指標=
0
,軌跡球=
0
,翻轉=
0
。
:Dropped: keys=
0
pointers=
0
trackballs=
0
flips=
0
//網路統計經過時間為4202ms,其中4202ms是用於在手機上的,0ms用於無線網路上,沒有連線的時間為0ms。
## Network stats: elapsed time=4202ms (4202ms mobile, 0ms wifi, 0ms not connected)
//monkey測試完成。
// Monkey finished
從例子中可以看出,該程式在這次測試中沒有問題,若程式出現問題終端將打印出異常供程式設計師查詢錯誤。
2、以下是monkey命令列的一些引數:
-p:所在測試的包,可以是一個也可以是多個 如 monkey -p com.androd.sms -p com.androd.explorer
-c:如果用此引數指定了一個或幾個類別,Monkey將只允許系統啟動被這些類別中的某個類別列出的Activity。如果不指定任何類別,Monkey將選擇下列類別中列出的Activity: Intent.CATEGORY_LAUNCHER或Intent.CATEGORY_MONKEY。要指定多個類別,需要使用多個-c選項,每個-c選項只能用於一個類別。
-ignore-crash:當應用程式崩潰或發生任何失控異常時,Monkey將停止執行。如果設定此選項,Monkey將繼續向系統傳送事件,直到計數完成。
-ignore-timeouts:通常,當應用程式發生任何超時錯誤(如“Application Not Responding”對話方塊)時,Monkey將停止執行。如果設定此選項,Monkey將繼續向系統傳送事件,直到計數完成。
-ignore-security-exceptions:通常,當應用程式發生許可錯誤(如啟動一個需要某些許可的Activity)時,Monkey將停止執行。如果設定了此選項,Monkey將繼續向系統傳送事件,直到計數完成。
-monitor-
native
-crashes:監視並報告Android系統中原生代碼的崩潰事件。如果設定了–kill-process-after-error,系統將停止執行。
-kill-process-after-error:如果程式出現錯誤,monkey將結束此程式程序。
-hprof:設定此項,將在monkey事件序列之前和之後立即生成profilling報告。這將會在data/misc中生成大檔案(約5mb)所以要小心使用它。
-pct-touch:調整觸控事件的百分比(觸控事件是一個down-up事件,它發生在螢幕的某單一位置)。
-pct-motion:動作事件的百分比(動作事件由螢幕上某處的一個down事件、一系列的隨機事件和一個up事件組成)。
-pct-trackball:調整軌跡事件的百分比(軌跡事件由一個或幾個隨機移動組成,有時還伴隨著點選)。
-pct-syskeys:調整系統按鍵事件的百分比(這些按鍵通常被保留,由系統使用,如home,back,start call,end call及音量控制)。
-pct-nav 調整基本導航事件的百分比(導航事件來自方向輸入裝置的up/down/left/right組成)。
-pct-majornav:調整“主要”導航事件的百分比(這些導航事件通常引發圖形介面中的動作,如:
5
-way鍵盤的中間按鍵、回退按鍵、選單按鍵)
-pct-appswitch:調整啟動Activity的百分比。在隨機間隔裡,Monkey將執行一個startActivity()呼叫,作為最大程度覆蓋包中全部Activity的一種方法。
-pct-anyevent:調整啟動Activity的百分比。它包羅了所有其它的事件型別,如:按鍵,其它不常用的裝置按鈕。
-pct-flip:
–wait-dbg:停止執行中的Monkey,直到有偵錯程式和它相連線。
–dbg-no-events:設定此選項,Monkey將執行初始啟動,進入到一個測試Activity,然後不會再進一步生成事件。為了得到最佳結果,把它與-v、一個或幾個包約束、以及一個保持Monkey執行
30
秒或更長時間的非零值聯合起來,從而提供一個環境,可以監視應用程式所呼叫的包之間的轉換。
-setup:
-f:
-port:為monkey開啟專用埠。此時只monkey不會幫你亂點選,而此時你自己就是一隻monkey了,在你亂點的時候,monkey會輸出你點選後回饋的資訊。如果你打完命令之後模擬器上沒有啟動你所要啟動的包,你需要自己啟動,但是你只能啟動你-p中指定的那幾個包。ctrl+c中斷。
--throttle :當事件起效時等待的毫秒數。
-s:隨機數生成器的seed值。如果用相同的seed值再次執行monkey,它將生成相同的事件序列。
COUNT:要傳送的事件數。
usage: monkey [-p ALLOWED_PACKAGE [-p ALLOWED_PACKAGE] ...]
[-c MAIN_CATEGORY [-c MAIN_CATEGORY] ...]
[--ignore-crashes] [--ignore-timeouts]
[--ignore-security-exceptions] [--monitor-
native
-crashes]
[--kill-process-after-error] [--hprof]
[--pct-touch PERCENT] [--pct-motion PERCENT]
[--pct-trackball PERCENT] [--pct-syskeys PERCENT]
[--pct-nav PERCENT] [--pct-majornav PERCENT]
[--pct-appswitch PERCENT] [--pct-flip PERCENT]
[--pct-anyevent PERCENT]
[--wait-dbg] [--dbg-no-events]
[--setup scriptfile] [-f scriptfile [-f scriptfile] ...]
[--port port]
[-s SEED] [-v [-v] ...] [--throttle MILLISEC]
COUNT
3、Monkey測試結果 :
# monkey -p wfh.LessonTable -v -v -v
200
:Monkey: seed=
0
count=
200
:AllowPackage: wfh.LessonTable
:IncludeCategory: android.intent.category.LAUNCHER
:IncludeCategory: android.intent.category.MONKEY
// Selecting main activities from category android.intent.category.LAUNCHER
// - NOT USING main activity com.android.browser.BrowserActivity (from package com.android.browser)
// - NOT USING main activity com.android.music.MusicBrowserActivity (from package com.android.music)
// - NOT USING main activity com.android.contacts.DialtactsActivity (from package com.android.contacts)
// - NOT USING main activity com.android.contacts.DialtactsContactsEntryActivity (from package com.android.contacts)
// - NOT USING main activity com.android.mms.ui.ConversationList (from package com.android.mms)
// - NOT USING main activity com.android.spare_parts.SpareParts (from package com.android.spare_parts)
// - NOT USING main activity com.android.camera.Camera (from package com.android.camera)
// - NOT USING main activity com.android.alarmclock.AlarmClock (from package com.android.alarmclock)
// - NOT USING main activity com.android.settings.Settings (from package com.android.settings)
// - NOT USING main activity com.android.camera.GalleryPicker (from package com.android.gallery)
// - NOT USING main activity com.android.email.activity.Welcome (from package com.android.email)
// - NOT USING main activity com.example.android.apis.ApiDemos (from package com.example.android.apis)
// - NOT USING main activity com.android.calculator2.Calculator (from package com.android.calculator2)
// - NOT USING main activity com.android.customlocale.CustomLocaleActivity (from package com.android.customlocale)
// - NOT USING main activity com.android.development.Development (from package com.android.development)
// - NOT USING main activity com.myactivity.MyActivity (from package com.myactivity)
// + Using main activity wfh.LessonTable.MainTable (from package wfh.LessonTable)
// - NOT USING main activity wfh.rss.MainRSS (from package wfh.rss)
// Selecting main activities from category android.intent.category.MONKEY
// - NOT USING main activity com.android.launcher.Launcher (from package com.android.launcher)
// - NOT USING main activity com.android.settings.ManageApplications (from package com.android.settings)
// - NOT USING main activity com.android.settings.RunningServices (from package com.android.settings)
// Seeded: 0
// Event percentages:
// 0: 15.0%
// 1: 10.0%
// 2: 15.0%
// 3: 25.0%
// 4: 15.0%
// 5: 2.0%
// 6: 2.0%
// 7: 1.0%
// 8: 15.0%
:Switch: #Intent;action=android.intent.action.MAIN;category=android.intent.category.LAUNCHER;launchFlags=
0x10000000
;component=wfh.LessonTable/.MainTable;end
// Allowing start of Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=wfh.LessonTable/.MainTable } in package wfh.LessonTable
Sleeping
for
0
milliseconds
:SendKey (ACTION_DOWN):
21
// KEYCODE_DPAD_LEFT
:SendKey (ACTION_UP):
21
// KEYCODE_DPAD_LEFT
Sleeping
for
0
milliseconds
//------------------------------------用--throttle來設定一個起效的事件發生後時延時。
:Sending Pointer ACTION_MOVE x=-
4.0
y=
2.0
:Sending Pointer ACTION_MOVE x=-
5.0
y=-
4.0
:Sending Pointer ACTION_MOVE x=
0.0
y=-
1.0
:Sending Pointer ACTION_MOVE x=-
3.0
y=
2.0
:Sending Pointer ACTION_MOVE x=-
4.0
y=
2.0
//-------------移動事件!!!
:Sending Pointer ACTION_MOVE x=-
2.0
y=
4.0
:Sending Pointer ACTION_MOVE x=
4.0
y=
1.0
:Sending Pointer ACTION_MOVE x=-
5.0
y=
4.0
:Sending Pointer ACTION_MOVE x=-
5.0
y=
1.0
:Sending Pointer ACTION_MOVE x=
0.0
y=-
2.0
:Sending Pointer ACTION_DOWN x=
0.0
y=
0.0
:Sending Pointer ACTION_UP x=
0.0
y=
0.0
Sleeping
for
0
milliseconds
:SendKey (ACTION_DOWN):
82
// KEYCODE_MENU
:SendKey (ACTION_UP):
82
// KEYCODE_MENU
Sleeping
for
0
milliseconds
:SendKey (ACTION_DOWN):
64
// KEYCODE_EXPLORER
:SendKey (ACTION_UP):
64
// KEYCODE_EXPLORER
Sleeping
for
0
milliseconds
:SendKey (ACTION_DOWN):
23
// KEYCODE_DPAD_CENTER
:SendKey (ACTION_UP):
23
// KEYCODE_DPAD_CENTER
Sleeping
for
0
milliseconds
:SendKey (ACTION_DOWN):
91
// KEYCODE_MUTE
// Allowing start of Intent { cmp=wfh.LessonTable/.EditLesson } in package wfh.LessonTable
:SendKey (ACTION_UP):
91
// KEYCODE_MUTE
Sleeping
for
0
milliseconds
:Sending Pointer ACTION_DOWN x=
207.0
y=
282.0
:Sending Pointer ACTION_MOVE x=
210.0
y=
277.0
:Sending Pointer ACTION_MOVE x=
204.0
y=
283.0
:Sending Pointer ACTION_MOVE x=
205.0
y=
278.0
:Sending Pointer ACTION_MOVE x=
199.0
y=
278.0
:Sending Pointer ACTION_MOVE x=
199.0
y=
287.0
:Sending Pointer ACTION_MOVE x=
194.0
y=
295.0
:Sending Pointer ACTION_MOVE x=
198.0
y=
290.0
:Sending Pointer ACTION_MOVE x=
197.0
y=
286.0
:Sending Pointer ACTION_MOVE x=
189.0
y=
289.0
:Sending Pointer ACTION_UP x=
189.0
y=
289.0
Sleeping
for
0
milliseconds
:SendKey (ACTION_DOWN):
56
// KEYCODE_PERIOD
:SendKey (ACTION_UP):
56
// KEYCODE_PERIOD
Sleeping
for
0
milliseconds
:Sending Pointer ACTION_DOWN x=
95.0
y=
259.0
:Sending Pointer ACTION_UP x=
95.0
y=
259.0
Sleeping
for
0
milliseconds
:Sending Pointer ACTION_DOWN x=
295.0
y=
223.0
:Sending Pointer ACTION_MOVE x=
291.0
y=
223.0
:Sending Pointer ACTION_MOVE x=
291.0
y=
218.0
:Sending Pointer ACTION_MOVE x=
284.0
y=
215.0
:Sending Pointer ACTION_MOVE x=
284.0
y=
206.0
:Sending Pointer ACTION_MOVE x=
285.0
y=
205.0
:Sending Pointer ACTION_MOVE x=
290.0
y=
213.0
:Sending Pointer ACTION_UP x=
290.0
y=
213.0
Sleeping
for
0
milliseconds
:SendKey (ACTION_DOWN):
82
// KEYCODE_MENU
:SendKey (ACTION_UP):
82
// KEYCODE_MENU
Sleeping
for
0
milliseconds
:Sending Pointer ACTION_MOVE x=-
5.0
y=
3.0
:Sending Pointer ACTION_MOVE x=
3.0
y=
2.0
:Sending Pointer ACTION_MOVE x=-
1.0
y=
2.0
:Sending Pointer ACTION_MOVE x=-
4.0
y=
4.0
:Sending Pointer ACTION_MOVE x=-
4.0
y=
0.0
:Sending Pointer ACTION_MOVE x=-
2.0
y=
2.0
:Sending Pointer ACTION_MOVE x=
3.0
y=
2.0
:Sending Pointer ACTION_MOVE x=-
2.0
y=-
5.0
:Sending Pointer ACTION_MOVE x=
1.0
y=
4.0
:Sending Pointer ACTION_MOVE x=-
4.0
y=-
5.0
:SendKey (ACTION_DOWN):
21
// KEYCODE_DPAD_LEFT
:SendKey (ACTION_UP):
21
// KEYCODE_DPAD_LEFT
Sleeping
for
0
milliseconds
:Sending Pointer ACTION_MOVE x=
0.0
y=-
5.0
:Sending Pointer ACTION_MOVE x=
3.0
y=-
5.0
:Sending Pointer ACTION_MOVE x=
4.0
y=
0.0
:Sending Pointer ACTION_MOVE x=-
4.0
y=
3.0
:Sending Pointer ACTION_MOVE x=
4.0
y=
1.0
:Sending Pointer ACTION_MOVE x=-
4.0
y=
3.0
:Sending Pointer ACTION_MOVE x=-
1.0
y=-
4.0
:Sending Pointer ACTION_MOVE x=-
2.0
y=-
2.0
:Sending Pointer ACTION_MOVE x=-
4.0
y=-
3.0
:Sending Pointer ACTION_MOVE x=-
5.0
y=-
1.0
:SendKey (ACTION_DOWN):
3
// KEYCODE_HOME
:SendKey (ACTION_UP):
3
// KEYCODE_HOME
// Rejecting start of Intent { act=android.intent.action.MAIN cat=[android.intent.category.HOME] cmp=com.android.launcher/.Launcher } in package com.android.launcher
Sleeping
for
0
milliseconds
:Sending Pointer ACTION_DOWN x=
74.0
y=
201.0
:Sending Pointer ACTION_UP x=
74.0
y=
201.0
Sleeping
for
0
milliseconds
:SendKey (ACTION_DOWN):
23
// KEYCODE_DPAD_CENTER
:SendKey (ACTION_UP):
23
// KEYCODE_DPAD_CENTER
Sleeping
for
0
milliseconds
:Sending Pointer ACTION_MOVE x=
3.0
y=-
2.0
:Sending Pointer ACTION_MOVE x=-
2.0
y=-
1.0
:Sending Pointer ACTION_MOVE x=-
5.0
y=
4.0
:Sending Pointer ACTION_MOVE x=-
2.0
y=
0.0
:Sending Pointer ACTION_MOVE x=
3.0
y=
2.0
:Sending Pointer ACTION_MOVE x=
0.0
y=
0.0
:Sending Pointer ACTION_MOVE x=
4.0
y=
3.0
:Sending Pointer ACTION_MOVE x=-
3.0
y=-
1.0
:Sending Pointer ACTION_MOVE x=-
4.0
y=
1.0
:Sending Pointer ACTION_MOVE x=-
5.0
y=
1.0
:Sending Pointer ACTION_DOWN x=
0.0
y=
0.0
:Sending Pointer ACTION_UP x=
0.0
y=
0.0
Sleeping
for
0
milliseconds
:SendKey (ACTION_DOWN):
21
// KEYCODE_DPAD_LEFT
:SendKey (ACTION_UP):
21
// KEYCODE_DPAD_LEFT
// activityResuming(wfh.LessonTable)
Sleeping
for
0
milliseconds
:SendKey (ACTION_DOWN):
82
// KEYCODE_MENU
:SendKey (ACTION_UP):
82
// KEYCODE_MENU
Sleeping
for
0
milliseconds
:SendKey (ACTION_DOWN):
20
// KEYCODE_DPAD_DOWN
:SendKey (ACTION_UP):
20
// KEYCODE_DPAD_DOWN
Sleeping
for
0
milliseconds
:SendKey (ACTION_DOWN):
20
// KEYCODE_DPAD_DOWN
:SendKey (ACTION_UP):
20
// KEYCODE_DPAD_DOWN
Sleeping
for
0
milliseconds
:SendKey (ACTION_DOWN):
21
// KEYCODE_DPAD_LEFT
:SendKey (ACTION_UP):
21
// KEYCODE_DPAD_LEFT
Sleeping
for
0
milliseconds ??????
:Sending Pointer ACTION_MOVE x=-
4.0
y=
2.0
:Sending Pointer ACTION_MOVE x=
4.0
y=
0.0
// Sending event #100
:Sending Pointer ACTION_MOVE x=
3.0
y=
0.0
:Sending Pointer ACTION_MOVE x=
3.0
y=
1.0
:Sending Pointer ACTION_MOVE x=
3.0
y=-
5.0
:Sending Pointer ACTION_MOVE x=-
4.0
y=
3.0
:Sending Pointer ACTION_MOVE x=
1.0
y=-
2.0
:Sending Pointer ACTION_MOVE x=
0.0
y=
2.0
:Sending Pointer ACTION_MOVE x=-
2.0
y=
1.0
:Sending Pointer ACTION_MOVE x=
2.0
y=-
1.0
:Sending Pointer ACTION_MOVE x=
4.0
y=
2.0
:Sending Pointer ACTION_MOVE x=-
1.0
y=
2.0
:Sending Pointer ACTION_MOVE x=
3.0
y=-
3.0
:Sending Pointer ACTION_MOVE x=
4.0
y=
0.0
:Sending Pointer ACTION_MOVE x=
0.0
y=-
1.0
:Sending Pointer ACTION_MOVE x=
4.0
y=-
1.0
:Sending Pointer ACTION_MOVE x=-
4.0
y=
4.0
:Sending Pointer ACTION_MOVE x=
4.0
y=
4.0
:Sending Pointer ACTION_MOVE x=-
4.0
y=
2.0
:Sending Pointer ACTION_MOVE x=
2.0
y=-
2.0
:SendKey (ACTION_DOWN):
22
// KEYCODE_DPAD_RIGHT
:SendKey (ACTION_UP):
22
// KEYCODE_DPAD_RIGHT
Sleeping
for
0
milliseconds
:SendKey (ACTION_DOWN):
53
// KEYCODE_Y
:SendKey (ACTION_UP):
53
// KEYCODE_Y
Sleeping
for
0
milliseconds
:SendKey (ACTION_DOWN):
24
// KEYCODE_VOLUME_UP
:SendKey (ACTION_UP):
24
// KEYCODE_VOLUME_UP
Sleeping
for
0
milliseconds
:SendKey (ACTION_DOWN):
82
// KEYCODE_MENU
:SendKey (ACTION_UP):
82
// KEYCODE_MENU
Sleeping
for
0
milliseconds
:Sending Pointer ACTION_DOWN x=
149.0
y=
150.0
:Sending Pointer ACTION_MOVE x=
149.0
y=
151.0
:Sending Pointer ACTION_MOVE x=
152.0
y=
158.0
:Sending Pointer ACTION_MOVE x=
148.0
y=
162.0
:Sending Pointer ACTION_MOVE x=
148.0
y=
156.0
:Sending Pointer ACTION_MOVE x=
152.0
y=
149.0
:Sending Pointer ACTION_MOVE x=
155.0
y=
146.0
:Sending Pointer ACTION_MOVE x=
150.0
y=
138.0
:Sending Pointer ACTION_MOVE x=
155.0
y=
142.0
:Sending Pointer ACTION_MOVE x=
162.0
y=
150.0
:Sending Pointer ACTION_UP x=
162.0
y=
150.0
Sleeping
for
0
milliseconds
:SendKey (ACTION_DOWN):
82
// KEYCODE_MENU
:SendKey (ACTION_UP):
82
// KEYCODE_MENU
// Allowing start of Intent { cmp=wfh.LessonTable/.AWeekLesson } in package wfh.LessonTable
Sleeping
for
0
milliseconds
:Sending Pointer ACTION_MOVE x=
0.0
y=-
1.0
:Sending Pointer ACTION_MOVE x=-
2.0
y=
0.0
:Sending Pointer ACTION_MOVE x=
2.0
y=
2.0
:Sending Pointer ACTION_MOVE x=-
5.0
y=-
1.0
:Sending Pointer ACTION_MOVE x=-
1.0
y=
0.0
:Sending Pointer ACTION_MOVE x=-
4.0
y=
4.0
:Sending Pointer ACTION_MOVE x=
4.0
y=
4.0
:Sending Pointer ACTION_MOVE x=
3.0
y=-
2.0
:Sending Pointer ACTION_MOVE x=
2.0
y=
2.0
:Sending Pointer ACTION_MOVE x=-
1.0
y=-
1.0
:SendKey (ACTION_DOWN):
19
// KEYCODE_DPAD_UP
:SendKey (ACTION_UP):
19
// KEYCODE_DPAD_UP
Sleeping
for
0
milliseconds
:Sending Pointer ACTION_DOWN x=
134.0
y=
239.0
:Sending Pointer ACTION_UP x=
134.0
y=
239.0
Sleeping
for
0
milliseconds
:SendKey (ACTION_DOWN):
4
// KEYCODE_BACK
:SendKey (ACTION_UP):
4
// KEYCODE_BACK
Sleeping
for
0
milliseconds
:SendKey (ACTION_DOWN):
23
// KEYCODE_DPAD_CENTER
// activityResuming(wfh.LessonTable)
:SendKey (ACTION_UP):
23
// KEYCODE_DPAD_CENTER
Sleeping
for
0
milliseconds
:SendKey (ACTION_DOWN):
22
// KEYCODE_DPAD_RIGHT
:SendKey (ACTION_UP):
22
// KEYCODE_DPAD_RIGHT
Sleeping
for
0
milliseconds
:SendKey (ACTION_DOWN):
19
// KEYCODE_DPAD_UP
:SendKey (ACTION_UP):
19
// KEYCODE_DPAD_UP
Sleeping
for
0
milliseconds
:SendKey (ACTION_DOWN):
21
// KEYCODE_DPAD_LEFT
:SendKey (ACTION_UP):
21
// KEYCODE_DPAD_LEFT
Sleeping
for
0
milliseconds
:SendKey (ACTION_DOWN):
19
// KEYCODE_DPAD_UP
:SendKey (ACTION_UP):
19
// KEYCODE_DPAD_UP
Sleeping
for
0
milliseconds
:SendKey (ACTION_DOWN):
23
// KEYCODE_DPAD_CENTER
:SendKey (ACTION_UP):
23
// KEYCODE_DPAD_CENTER
Sleeping
for
0
milliseconds
:Sending Pointer ACTION_DOWN x=
118.0
y=
37.0
:Sending Pointer ACTION_MOVE x=
119.0
y=
33.0
:Sending Pointer ACTION_UP x=
119.0
y=
33.0
Sleeping
for
0
milliseconds
:Sending Pointer ACTION_DOWN x=
297.0
y=
358.0
:Sending Pointer ACTION_MOVE x=
289.0
y=
363.0
:Sending Pointer ACTION_MOVE x=
284.0
y=
369.0
:Sending Pointer ACTION_UP x=
284.0
y=
369.0
Sleeping
for
0
milliseconds
:Sending Pointer ACTION_DOWN x=
258.0
y=
403.0
:Sending Pointer ACTION_MOVE x=
249.0
y=
398.0
:Sending Pointer ACTION_MOVE x=
258.0
y=
393.0
:Sending Pointer ACTION_MOVE x=
258.0
y=
402.0
:Sending Pointer ACTION_MOVE x=
263.0
y=
395.0
:Sending Pointer ACTION_MOVE x=
266.0
y=
399.0
:Sending Pointer ACTION_MOVE x=
273.0
y=
403.0
:Sending Pointer ACTION_UP x=
273.0
y=
403.0
Sleeping
for
0
milliseconds
:Sending Pointer ACTION_MOVE x=-
5.0
y=-
5.0
:Sending Pointer ACTION_MOVE x=
1.0
y=-
2.0
:Sending Pointer ACTION_MOVE x=
1.0
y=-
4.0
:Sending Pointer ACTION_MOVE x=-
2.0
y=
2.0
:Sending Pointer ACTION_MOVE x=
3.0
y=-
3.0
:Sending Pointer ACTION_MOVE x=
2.0
y=-
4.0
:Sending Pointer ACTION_MOVE x=-
5.0
y=
2.0
:Sending Pointer ACTION_MOVE x=
0.0
y=
0.0
當測試到ACTION_MOVE x=
0.0
y=
0.0
這個動作時,發生了FC(Force Close)錯誤,以下為輸出錯誤資訊。同時在LogCat裡面也有錯誤輸出,而且LogCat裡面的錯誤資訊更為詳細,在實際的測試中應該結合兩者輸出的資訊進行除錯程式。
// CRASH: wfh.LessonTable (pid 1973)
// Short Msg: java.lang.NullPointerException
// Long Msg: java.lang.NullPointerException
// Build Label: android:generic/sdk/generic/:2.1-update1/ECLAIR/35983:eng/test-keys
// Build Changelist: 35983
// Build Time: 1273161972
// ID:
// Tag: AndroidRuntime
// java.lang.NullPointerException:
// at android.widget.TabHost.dispatchKeyEvent(TabHost.java:279)
// at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:748)
// at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:748)
// at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:748)
// at android.widget.TabHost.dispatchKeyEvent(TabHost.java:275)
// at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:748)
// at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:748)
// at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:748)
// at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchKeyEvent(PhoneWindow.java:1655)
// at com.android.internal.policy.impl.PhoneWindow.superDispatchKeyEvent(PhoneWindow.java:1102)
// at android.app.Activity.dispatchKeyEvent(Activity.java:2038)
// at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchKeyEvent(PhoneWindow.java:1631)
// at android.view.ViewRoot.deliverKeyEventToViewHierarchy(ViewRoot.java:2368)
// at android.view.ViewRoot.handleFinishedEvent(ViewRoot.java:2338)
// at android.view.ViewRoot.handleMessage(ViewRoot.java:1641)
// at android.os.Handler.dispatchMessage(Handler.java:99)
// at android.os.Looper.loop(Looper.java:123)
// at android.app.ActivityThread.main(ActivityThread.java:4363)
// at java.lang.reflect.Method.invokeNative(Method.java:-2)
// at java.lang.reflect.Method.invoke(Method.java:521)
// at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
// at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
// at dalvik.system.NativeStart.main(NativeStart.java:-2)
** Monkey aborted due to error.
Events injected:
190
:Dropped: keys=
0
pointers=
11
trackballs=
0
flips=
0
## Network stats: elapsed time=27954ms (27954ms mobile, 0ms wifi, 0ms not connected)
** System appears to have crashed at event
190
of
200
using seed
0
#
開始monkey測試時android的LogCat輸出的資訊:
11
-
01
08
:
52
:
53.712
: DEBUG/AndroidRuntime(
2077
): >>>>>>>>>>>>>> AndroidRuntime START <<<<<<<<<<<<<<
11
-
01
08
:
52
:
53.742
: DEBUG/AndroidRuntime(
2077
): CheckJNI is ON
11
-
01
08
:
52
:
54.453
: DEBUG/AndroidRuntime(
2077
): --- registering
native
functions ---
11
-
01
08
:
52
:
55.542
: DEBUG/ddm-heap(
2077
): Got feature list request
11
-
01
08
:
52
:
59.533
: INFO/ActivityManager(
53
): Starting activity: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=
0x10000000
cmp=wfh.LessonTable/.MainTable }
11
-
01
08
:
53
:
00.842
: INFO/ActivityManager(
53
): Displayed activity wfh.LessonTable/.MainTable:
1266
ms (total
1266
ms)
11
-
01
08
:
53
:
03.123
: DEBUG/dalvikvm(
1973
): GC freed
7524
objects /
507616
bytes in 246ms
11
-
01
08
:
53
:
03.173
: INFO/dalvikvm(
1973
): Uncaught exception thrown by finalizer (will be discarded):
11
-
01
08
:
53
:
03.213
: INFO/dalvikvm(
1973
): Ljava/lang/IllegalStateException;: Finalizing cursor android.database.sqlite.SQLiteCursor
@43c585c0
on MO that has not been deactivated or closed
11
-
01
08
:
53
:
03.213
: INFO/dalvikvm(
1973
): at android.database.sqlite.SQLiteCursor.finalize(SQLiteCursor.java:
596
)
11
-
01
08
:
53
:
03.213
: INFO/dalvikvm(
1973
): at dalvik.system.NativeStart.run(Native Method)
11
-
01
08
:
53
:
03.233
: INFO/dalvikvm(
1973
): Uncaught exception thrown by finalizer (will be discarded):
11
-
01
08
:
53
:
03.252
: INFO/dalvikvm(
1973
): Ljava/lang/IllegalStateException;: Finalizing cursor android.database.sqlite.SQLiteCursor
@43c57f98
on MO that has not been deactivated or closed
11
-
01
08
:
53
:
03.252
: INFO/dalvikvm(
1973
): at android.database.sqlite.SQLiteCursor.finalize(SQLiteCursor.java:
596
)
11
-
01
08
:
53
:
03.252
: INFO/dalvikvm(
1973
): at dalvik.system.NativeStart.run(Native Method)
11
-
01
08
:
53
:
03.263
: INFO/dalvikvm(
1973
): Uncaught exception thrown by finalizer (will be discarded):
11
-
01
08
:
53
:
03.293
: INFO/dalvikvm(
1973
): Ljava/lang/IllegalStateException;: Finalizing cursor android.database.sqlite.SQLiteCursor
@43c57970
on MO that has not been deactivated or closed
11
-
01
08
:
53
:
03.293
: INFO/dalvikvm(
1973
): at android.database.sqlite.SQLiteCursor.finalize(SQLiteCursor.java:
596
)
11
-
01
08
:
53
:
03.303
: INFO/dalvikvm(
1973
): at dalvik.system.NativeStart.run(Native Method)
11
-
01
08
:
53
:
03.323
: INFO/dalvikvm(
1973
): Uncaught exception thrown by finalizer (will be discarded):
11
-
01
08
:
53
:
03.323
: INFO/dalvikvm(
1973
): Ljava/lang/IllegalStateException;: Finalizing cursor android.database.sqlite.SQLiteCursor
@43c57330
on MO that has not been deactivated or closed
11
-
01
08
:
53
:
03.333
: INFO/dalvikvm(
1973
): at android.database.sqlite.SQLiteCursor.finalize(SQLiteCursor.java:
596
)
11
-
01
08
:
53
:
03.353
: INFO/dalvikvm(
1973
): at dalvik.system.NativeStart.run(Native Method)
11
-
01
08
:
53
:
03.363
: INFO/dalvikvm(
1973
): Uncaught exception thrown by finalizer (will be discarded):
11
-
01
08
:
53
:
03.403
: INFO/dalvikvm(
1973
): Ljava/lang/IllegalStateException;: Finalizing cursor android.database.sqlite.SQLiteCursor
@43c45330
on MO that has not been deactivated or closed
11
-
01
08
:
53
:
03.403
: INFO/dalvikvm(
1973
): at android.database.sqlite.SQLiteCursor.finalize(SQLiteCursor.java:
596
)
11
-
01
08
:
53
:
03.403
: INFO/dalvikvm(
1973
): at dalvik.system.NativeStart.run(Native Method)
11
-
01
08
:
53
:
03.423
: INFO/dalvikvm(
1973
): Uncaught exception thrown by finalizer (will be discarded):
11
-
01
08
:
53
:
03.433
: INFO/dalvikvm(
1973
): Ljava/lang/IllegalStateException;: Finalizing cursor android.database.sqlite.SQLiteCursor
@43c44d08
on MO that has not been deactivated or closed
11
-
01
08
:
53
:
03.443
: INFO/dalvikvm(
1973
): at android.database.sqlite.SQLiteCursor.finalize(SQLiteCursor.java:
596
)
11
-
01
08
:
53
:
03.443
: INFO/dalvikvm(
1973
): at dalvik.system.NativeStart.run(Native Method)
11
-
01
08
:
53
:
03.453
: INFO/dalvikvm(
1973
): Uncaught exception thrown by finalizer (will be discarded):
11
-
01
08
:
53
:
03.483
: INFO/dalvikvm(
1973
): Ljava/lang/IllegalStateException;: Finalizing cursor android.database.sqlite.SQLiteCursor
@43c446c8
on MO that has not been deactivated or closed
11
-
01
08
:
53
:
03.483
: INFO/dalvikvm(
1973
): at android.database.sqlite.SQLiteCursor.finalize(SQLiteCursor.java:
596
)
11
-
01
08
:
53
:
03.503
: INFO/dalvikvm(
1973
): at dalvik.system.NativeStart.run(Native Method)
11
-
01
08
:
53
:
03.523
: INFO/dalvikvm(
1973
): Uncaught exception thrown by finalizer (will be discarded):
11
-
01
08
:
53
:
03.563
: INFO/dalvikvm(
1973
): Ljava/lang/IllegalStateException;: Finalizing cursor android.database.sqlite.SQLiteCursor
@43c26288
on MO that has not been deactivated or closed
11
-
01
08
:
53
:
03.572
: INFO/dalvikvm(
1973
): at android.database.sqlite.SQLiteCursor.finalize(SQLiteCursor.java:
596
)
11
-
01
08
:
53
:
03.572
: INFO/dalvikvm(
1973
): at dalvik.system.NativeStart.run(Native Method)
11
-
01
08
:
53
:
03.622
: INFO/dalvikvm(
1973
): Uncaught exception thrown by finalizer (will be discarded):
11
-
01
08
:
53
:
03.642
: INFO/dalvikvm(
1973
): Ljava/lang/IllegalStateException;: Finalizing cursor android.database.sqlite.SQLiteCursor
@43c25cb0
on MO that has not been deactivated or closed
11
-
01
08
:
53
:
03.642
: INFO/dalvikvm(
1973
): at android.database.sqlite.SQLiteCursor.finalize(SQLiteCursor.java:
596
)
11
-
01
08
:
53
:
03.662
: INFO/dalvikvm(
1973
): at dalvik.system.NativeStart.run(Native Method)
11
-
01
08
:
53
:
03.662
: INFO/dalvikvm(
1973
): Uncaught exception thrown by finalizer (will be discarded):
11
-
01
08
:
53
:
03.722
: INFO/dalvikvm(
1973
): Ljava/lang/IllegalStateException;: Finalizing cursor android.database.sqlite.SQLiteCursor
@43c256d8
on MO that has not been deactivated or closed
11
-
01
08
:
53
:
03.722
: INFO/dalvikvm(
1973
): at android.database.sqlite.SQLiteCursor.finalize(SQLiteCursor.java:
596
)
11
-
01
08
:
53
:
03.722
: INFO/dalvikvm(
1973
): at dalvik.system.NativeStart.run(Native Method)
11
-
01
08
:
53
:
03.732
: INFO/dalvikvm(
1973
): Uncaught exception thrown by finalizer (will be discarded):
11
-
01
08
:
53
:
03.752
: INFO/dalvikvm(
1973
): Ljava/lang/IllegalStateException;: Finalizing cursor android.database.sqlite.SQLiteCursor
@43c250e8
on MO that has not been deactivated or closed
11
-
01
08
:
53
:
03.752
: INFO/dalvikvm(
1973
): at android.database.sqlite.SQLiteCursor.finalize(SQLiteCursor.java:
596
)
11
-
01
08
:
53
:
03.762
: INFO/dalvikvm(
1973
): at dalvik.system.NativeStart.run(Native Method)
11
-
01
08
:
53
:
03.902
: INFO/dalvikvm(
1973
): Uncaught exception thrown by finalizer (will be discarded):
11
-
01
08
:
53
:
03.902
: INFO/dalvikvm(
1973
): Ljava/lang/IllegalStateException;: Finalizing cursor android.database.sqlite.SQLiteCursor
@43c1e780
on MO that has not been deactivated or closed
11
-
01
08
:
53
:
03.902
: INFO/dalvikvm(
1973
): at android.database.sqlite.SQLiteCursor.finalize(SQLiteCursor.java:
596
)
11
-
01
08
:
53
:
03.912
: INFO/dalvikvm(
1973
): at dalvik.system.NativeStart.run(Native Method)
11
-
01
08
:
53
:
04.247
: WARN/KeyCharacterMap(
1973
): No keyboard
for
id
0
11
-
01
08
:
53
:
04.252
: WARN/KeyCharacterMap(
1973
): Using
default
keymap: /system/usr/keychars/qwerty.kcm.bin
11
-
01
08
:
53
:
04.762
: INFO/ActivityManager(
53
): Starting activity: Intent { cmp=wfh.LessonTable/.EditLesson }
11
-
01
08
:
53
:
05.233
: WARN/WindowManager(
53
): No window to dispatch pointer action
0
11
-
01
08
:
53
:
05.533
: WARN/WindowManager(
53
): No window to dispatch pointer action
1
11
-
01
08
:
53
:
06.782
: INFO/ActivityManager(
53
): Displayed activity wfh.LessonTable/.EditLesson:
1637
ms (total
1637
ms)
11
-
01
08
:
53
:
09.623
: WARN/ActivityManager(
53
): Launch timeout has expired, giving up wake lock!
11
-
01
08
:
53
:
09.682
: WARN/ActivityManager(
53
): Activity idle timeout
for
HistoryRecord{43d3ab48 wfh.LessonTable/.MainTable}
11
-
01
08
:
53
:
12.662
: INFO/ActivityManager(
53
): Starting activity: Intent { act=android.intent.action.MAIN cat=[android.intent.category.HOME] flg=
0x10200000
cmp=com.android.launcher/.Launcher }
11
-
01
08
:
53
:
15.433
: INFO/NotificationService(
53
): enqueueToast pkg=wfh.LessonTable callback=android.app.ITransientNotification$Stub$Proxy
@43d5b308
duration=
1
11
-
01
08
:
53
:
15.513
: INFO/System.out(
1973
): UpdateRecord
11
-
01
08
:
53
:
19.353
: INFO/NotificationService(
53
): enqueueToast pkg=android callback=android.widget.Toast$TN
@43ced790
duration=
0
11
-
01
08
:
53
:
19.752
: WARN/InputManagerService(
53
): Window already focused, ignoring focus gain of: com.android.internal.view.IInputMethodClient$Stub$Proxy
@43d2bab0
11
-
01
08
:
53
:
20.752
: INFO/ActivityManager(
53
): Starting activity: Intent { cmp=wfh.LessonTable/.AWeekLesson (has extras) }
11
-
01
08
:
53
:
21.852
: INFO/ActivityManager(
53
): Displayed activity wfh.LessonTable/.AWeekLesson:
1028
ms (total
1028
ms)
11
-
01
08
:
53
:
27.093
: DEBUG/AndroidRuntime(
1973