Andriod App之壓力測(cè)試Monkey

Monkey是一個(gè)耳熟能詳?shù)墓ぞ咭鸭瑁灰惶醡onkey很多人會(huì)說(shuō)曼氛,我知道桐款,能隨機(jī)發(fā)送一些操作命令使其在手機(jī)上執(zhí)行(發(fā)送偽隨機(jī)用戶(hù)事件的工具)

準(zhǔn)備工作

1、android操作系統(tǒng)的手機(jī)

2痒蓬、一臺(tái)電腦,通過(guò)usb線將電腦和手機(jī)進(jìn)行連接滴劲,并通過(guò)adb(Android debug bridge)操作手機(jī)里的Monkey命令

Adb安裝以及可能遇到的一些問(wèn)題攻晒,請(qǐng)參考“Android-USB-Monkey測(cè)試

官網(wǎng)參考連接

General--helpPrints a simple usage guide.

-vEach -v on the command line will increment the verbosity level. Level 0 (the default) provides little information beyond startup notification, test completion, and final results. Level 1 provides more details about the test as it runs, such as individual events being sent to your activities. Level 2 provides more detailed setup information such as activities selected or not selected for testing.

命令行的每一個(gè) -v 將增加反饋信息的級(jí)別。 Level 0( 缺省值 ) 除啟動(dòng)提示班挖、測(cè)試完成和最終結(jié)果之外鲁捏,提供較少信息。 Level 1 提供較為詳細(xì)的測(cè)試信息萧芙,如逐個(gè)發(fā)送到 Activity 的事件给梅。 Level 2 提供更加詳細(xì)的設(shè)置信息,如測(cè)試中被選中的或未被選中的 Activity 双揪。 事件


Events-s Seed value for pseudo-random number generator. If you re-run the Monkey with the same seed value, it will generate the same sequence of events.

偽隨機(jī)數(shù)生成器的 seed 值动羽。如果用相同的 seed 值再次運(yùn)行 Monkey ,它將生成相同的事件序列渔期。


--throttle Inserts a fixed delay between events. You can use this option to slow down the Monkey. If not specified, there is no delay and the events are generated as rapidly as possible.

在事件之間插入固定延遲运吓。通過(guò)這個(gè)選項(xiàng)可以減緩 Monkey 的執(zhí)行速度渴邦。如果不指定該選項(xiàng), Monkey 將不會(huì)被延遲拘哨,事件將盡可能快地被產(chǎn)成谋梭。


--pct-touch Adjust percentage of touch events. (Touch events are a down-up event in a single place on the screen.)

調(diào)整觸摸事件的百分比 ( 觸摸事件是一個(gè) down-up 事件,它發(fā)生在屏幕上的某單一位置 ) 倦青。


--pct-motion Adjust percentage of motion events. (Motion events consist of a down event somewhere on the screen, a series of pseudo-random movements, and an up event.)

調(diào)整動(dòng)作事件的百分比 ( 動(dòng)作事件由屏幕上某處的一個(gè) down 事件瓮床、一系列 的偽隨機(jī)事件和一個(gè) up 事件組成 ) 。


--pct-trackball Adjust percentage of trackball events. (Trackball events consist of one or more random movements, sometimes followed by a click.)

調(diào)整軌跡事件的百分比 ( 軌跡事件由一個(gè)或幾個(gè)隨機(jī)的移動(dòng)組成姨夹,有時(shí)還伴隨有點(diǎn)擊 ) 纤垂。


--pct-nav Adjust percentage of "basic" navigation events. (Navigation events consist of up/down/left/right, as input from a directional input device.)

調(diào)整“基本”導(dǎo)航事件的百分比 ( 導(dǎo)航事件由來(lái)自方向輸入設(shè)備的 up/down/left/right 組成 ) 。


--pct-majornav Adjust percentage of "major" navigation events. (These are navigation events that will typically cause actions within your UI, such as the center button in a 5-way pad, the back key, or the menu key.)

調(diào)整“主要”導(dǎo)航事件的百分比 ( 這些導(dǎo)航事件通常引發(fā)圖形界面中的動(dòng)作磷账,如: 5-way 鍵盤(pán)的中間按鍵峭沦、回退按鍵、菜單按鍵 )


--pct-syskeys Adjust percentage of "system" key events. (These are keys that are generally reserved for use by the system, such as Home, Back, Start Call, End Call, or Volume controls.)

調(diào)整“系統(tǒng)”按鍵事件的百分比 ( 這些按鍵通常被保留逃糟,由系統(tǒng)使用吼鱼,如 Home 、 Back 绰咽、 Start Call 菇肃、 End Call 及音量控制鍵 ) 。


--pct-appswitch Adjust percentage of activity launches. At random intervals, the Monkey will issue a startActivity() call, as a way of maximizing coverage of all activities within your package.

調(diào)整啟動(dòng) Activity 的百分比取募。在隨機(jī)間隔里琐谤, Monkey 將執(zhí)行一個(gè) startActivity () 調(diào)用,作為最大程度覆蓋包中全部 Activity 的一種方法玩敏。


--pct-anyevent Adjust percentage of other types of events. This is a catch-all for all other types of events such as keypresses, other less-used buttons on the device, and so forth.

調(diào)整其它類(lèi)型事件的百分比斗忌。它包羅了所有其它類(lèi)型的事件,如:按鍵旺聚、其它不常用的設(shè)備按鈕织阳、等等。 約束限制


Constraints-p If you specify one or more packages this way, the Monkey willonlyallow 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.

如果用此參數(shù)指定了一個(gè)或幾個(gè)包砰粹, Monkey 將只允許系統(tǒng)啟動(dòng)這些包里的 Activity 唧躲。如果你的應(yīng)用程序還需要訪問(wèn)其它包里的 Activity( 如選擇取一個(gè)聯(lián)系人 ) ,那些包也需要在此同時(shí)指定碱璃。如果不指定任何包弄痹, Monkey 將允許系統(tǒng)啟動(dòng)全部包里的 Activity 。要指定多個(gè)包嵌器,需要使用多個(gè) -p 選項(xiàng)界酒,每個(gè) -p 選項(xiàng)只能用于一個(gè)包。


-c If you specify one or more categories this way, the Monkey willonlyallow the system to visit activities that are listed with one of the specified categories. If you don't specify any categories, the Monkey will select activities listed with the category Intent.CATEGORY_LAUNCHER or Intent.CATEGORY_MONKEY. To specify multiple categories, use the -c option multiple times — one -c option per category.

如果用此參數(shù)指定了一個(gè)或幾個(gè)類(lèi)別嘴秸, Monkey 將只允許系統(tǒng)啟動(dòng)被這些類(lèi)別中的某個(gè)類(lèi)別列出的 Activity 毁欣。如果不指定任何類(lèi)別庇谆, Monkey 將選擇下列類(lèi)別中列出的 Activity : Intent.CATEGORY_LAUNCHER 或 Intent.CATEGORY_MONKEY 。要指定多個(gè)類(lèi)別凭疮,需要使用多個(gè) -c 選項(xiàng)饭耳,每個(gè) -c 選項(xiàng)只能用于一個(gè)類(lèi)別。


Debugging--dbg-no-eventsWhen specified, the Monkey will perform the initial launch into a test activity, but will not generate any further events. For best results, combine with -v, one or more package constraints, and a non-zero throttle to keep the Monkey running for 30 seconds or more. This provides an environment in which you can monitor package transitions invoked by your application.

設(shè)置此選項(xiàng)执解, Monkey 將執(zhí)行初始啟動(dòng)寞肖,進(jìn)入到一個(gè)測(cè)試 Activity ,然后不會(huì)再進(jìn)一步生成事件衰腌。為了得到最佳結(jié)果新蟆,把它與 -v 、一個(gè)或幾個(gè)包約束右蕊、以及一個(gè)保持 Monkey 運(yùn)行 30 秒或更長(zhǎng)時(shí)間的非零值聯(lián)合起來(lái)琼稻,從而提供一個(gè)環(huán)境,可以監(jiān)視應(yīng)用程序所調(diào)用的包之間的轉(zhuǎn)換饶囚。


--hprofIf set, this option will generate profiling reports immediately before and after the Monkey event sequence. This will generate large (~5Mb) files in data/misc, so use with care. SeeTraceviewfor more information on trace files.

設(shè)置此選項(xiàng)帕翻,將在 Monkey 事件序列之前和之后立即生成 profiling 報(bào)告。這將會(huì)在 data/misc 中生成大文件 (~5Mb) 萝风,所以要小心使用它嘀掸。

--ignore-crashesNormally, the Monkey will stop when the application crashes or experiences any type of unhandled exception. If you specify this option, the Monkey will continue to send events to the system, until the count is completed.

通常,當(dāng)應(yīng)用程序崩潰或發(fā)生任何失控異常時(shí)规惰, Monkey 將停止運(yùn)行睬塌。如果設(shè)置此選項(xiàng), Monkey 將繼續(xù)向系統(tǒng)發(fā)送事件歇万,直到計(jì)數(shù)完成衫仑。


--ignore-timeoutsNormally, the Monkey will stop when the application experiences any type of timeout error such as a "Application Not Responding" dialog. If you specify this option, the Monkey will continue to send events to the system, until the count is completed.

通常,當(dāng)應(yīng)用程序發(fā)生任何超時(shí)錯(cuò)誤 ( 如“ Application Not Responding ”對(duì)話框 ) 時(shí)堕花, Monkey 將停止運(yùn)行。如果設(shè)置此選項(xiàng)粥鞋, Monkey 將繼續(xù)向系統(tǒng)發(fā)送事件缘挽,直到計(jì)數(shù)完成。


--ignore-security-exceptionsNormally, the Monkey will stop when the application experiences any type of permissions error, for example if it attempts to launch an activity that requires certain permissions. If you specify this option, the Monkey will continue to send events to the system, until the count is completed.

通常呻粹,當(dāng)應(yīng)用程序發(fā)生許可錯(cuò)誤 ( 如啟動(dòng)一個(gè)需要某些許可的 Activity) 時(shí)壕曼, Monkey 將停止運(yùn)行。如果設(shè)置了此選項(xiàng)等浊, Monkey 將繼續(xù)向系統(tǒng)發(fā)送事件腮郊,直到計(jì)數(shù)完成。


--kill-process-after-errorNormally, when the Monkey stops due to an error, the application that failed will be left running. When this option is set, it will signal the system to stop the process in which the error occurred. Note, under a normal (successful) completion, the launched process(es) are not stopped, and the device is simply left in the last state after the final event.

通常筹燕,當(dāng) Monkey 由于一個(gè)錯(cuò)誤而停止時(shí)轧飞,出錯(cuò)的應(yīng)用程序?qū)⒗^續(xù)處于運(yùn)行狀態(tài)衅鹿。當(dāng)設(shè)置了此選項(xiàng)時(shí),將會(huì)通知系統(tǒng)停止發(fā)生錯(cuò)誤的進(jìn)程过咬。注意大渤,正常的 ( 成功的 ) 結(jié)束,并沒(méi)有停止啟動(dòng)的進(jìn)程掸绞,設(shè)備只是在結(jié)束事件之后泵三,簡(jiǎn)單地保持在最后的狀態(tài)。


--monitor-native-crashesWatches for and reports crashes occurring in the Android system native code. If --kill-process-after-error is set, the system will stop.

監(jiān)視并報(bào)告 Android 系統(tǒng)中本地代碼的崩潰事件衔掸。如果設(shè)置了 –kill-process-after-error 烫幕,系統(tǒng)將停止運(yùn)行。


--wait-dbgStops the Monkey from executing until a debugger is attached to it.

停止執(zhí)行中的 Monkey 敞映,直到有調(diào)試器和它相連接较曼。

PS:Monkey可以進(jìn)行一些隨機(jī)操作,但是估計(jì)操作可以借助MonkeyScript來(lái)完成

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
  • 序言:七十年代末驱显,一起剝皮案震驚了整個(gè)濱河市诗芜,隨后出現(xiàn)的幾起案子,更是在濱河造成了極大的恐慌埃疫,老刑警劉巖伏恐,帶你破解...
    沈念sama閱讀 217,185評(píng)論 6 503
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件,死亡現(xiàn)場(chǎng)離奇詭異栓霜,居然都是意外死亡翠桦,警方通過(guò)查閱死者的電腦和手機(jī),發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 92,652評(píng)論 3 393
  • 文/潘曉璐 我一進(jìn)店門(mén)胳蛮,熙熙樓的掌柜王于貴愁眉苦臉地迎上來(lái)销凑,“玉大人,你說(shuō)我怎么就攤上這事仅炊《酚祝” “怎么了?”我有些...
    開(kāi)封第一講書(shū)人閱讀 163,524評(píng)論 0 353
  • 文/不壞的土叔 我叫張陵抚垄,是天一觀的道長(zhǎng)蜕窿。 經(jīng)常有香客問(wèn)我,道長(zhǎng)呆馁,這世上最難降的妖魔是什么桐经? 我笑而不...
    開(kāi)封第一講書(shū)人閱讀 58,339評(píng)論 1 293
  • 正文 為了忘掉前任,我火速辦了婚禮浙滤,結(jié)果婚禮上阴挣,老公的妹妹穿的比我還像新娘。我一直安慰自己纺腊,他們只是感情好畔咧,可當(dāng)我...
    茶點(diǎn)故事閱讀 67,387評(píng)論 6 391
  • 文/花漫 我一把揭開(kāi)白布茎芭。 她就那樣靜靜地躺著,像睡著了一般盒卸。 火紅的嫁衣襯著肌膚如雪骗爆。 梳的紋絲不亂的頭發(fā)上,一...
    開(kāi)封第一講書(shū)人閱讀 51,287評(píng)論 1 301
  • 那天蔽介,我揣著相機(jī)與錄音摘投,去河邊找鬼。 笑死虹蓄,一個(gè)胖子當(dāng)著我的面吹牛犀呼,可吹牛的內(nèi)容都是我干的。 我是一名探鬼主播薇组,決...
    沈念sama閱讀 40,130評(píng)論 3 418
  • 文/蒼蘭香墨 我猛地睜開(kāi)眼外臂,長(zhǎng)吁一口氣:“原來(lái)是場(chǎng)噩夢(mèng)啊……” “哼!你這毒婦竟也來(lái)了律胀?” 一聲冷哼從身側(cè)響起宋光,我...
    開(kāi)封第一講書(shū)人閱讀 38,985評(píng)論 0 275
  • 序言:老撾萬(wàn)榮一對(duì)情侶失蹤,失蹤者是張志新(化名)和其女友劉穎炭菌,沒(méi)想到半個(gè)月后罪佳,有當(dāng)?shù)厝嗽跇?shù)林里發(fā)現(xiàn)了一具尸體,經(jīng)...
    沈念sama閱讀 45,420評(píng)論 1 313
  • 正文 獨(dú)居荒郊野嶺守林人離奇死亡黑低,尸身上長(zhǎng)有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點(diǎn)故事閱讀 37,617評(píng)論 3 334
  • 正文 我和宋清朗相戀三年赘艳,在試婚紗的時(shí)候發(fā)現(xiàn)自己被綠了。 大學(xué)時(shí)的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片克握。...
    茶點(diǎn)故事閱讀 39,779評(píng)論 1 348
  • 序言:一個(gè)原本活蹦亂跳的男人離奇死亡蕾管,死狀恐怖,靈堂內(nèi)的尸體忽然破棺而出菩暗,到底是詐尸還是另有隱情掰曾,我是刑警寧澤,帶...
    沈念sama閱讀 35,477評(píng)論 5 345
  • 正文 年R本政府宣布停团,位于F島的核電站旷坦,受9級(jí)特大地震影響,放射性物質(zhì)發(fā)生泄漏客蹋。R本人自食惡果不足惜,卻給世界環(huán)境...
    茶點(diǎn)故事閱讀 41,088評(píng)論 3 328
  • 文/蒙蒙 一孽江、第九天 我趴在偏房一處隱蔽的房頂上張望讶坯。 院中可真熱鬧,春花似錦岗屏、人聲如沸辆琅。這莊子的主人今日做“春日...
    開(kāi)封第一講書(shū)人閱讀 31,716評(píng)論 0 22
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽(yáng)婉烟。三九已至娩井,卻和暖如春,著一層夾襖步出監(jiān)牢的瞬間似袁,已是汗流浹背洞辣。 一陣腳步聲響...
    開(kāi)封第一講書(shū)人閱讀 32,857評(píng)論 1 269
  • 我被黑心中介騙來(lái)泰國(guó)打工, 沒(méi)想到剛下飛機(jī)就差點(diǎn)兒被人妖公主榨干…… 1. 我叫王不留昙衅,地道東北人扬霜。 一個(gè)月前我還...
    沈念sama閱讀 47,876評(píng)論 2 370
  • 正文 我出身青樓,卻偏偏與公主長(zhǎng)得像而涉,于是被迫代替她去往敵國(guó)和親著瓶。 傳聞我的和親對(duì)象是個(gè)殘疾皇子,可洞房花燭夜當(dāng)晚...
    茶點(diǎn)故事閱讀 44,700評(píng)論 2 354

推薦閱讀更多精彩內(nèi)容

  • **2014真題Directions:Read the following text. Choose the be...
    又是夜半驚坐起閱讀 9,491評(píng)論 0 23
  • Android Monkey整理 [TOC] 簡(jiǎn)介 Monkey是Android中的一個(gè)命令行工具啼县,可以運(yùn)行在模擬...
    流水不腐小夏閱讀 1,300評(píng)論 0 6
  • PLEASE READ THE FOLLOWING APPLE DEVELOPER PROGRAM LICENSE...
    念念不忘的閱讀 13,471評(píng)論 5 6
  • 廣州常年青山如黛材原,嫩綠長(zhǎng)溪,季節(jié)變化除了用氣溫來(lái)衡量外季眷,不是特別分明余蟹。一年四季看到頭,很容易產(chǎn)生審美疲勞瘟裸。但不能因...
    陌上心閱讀 816評(píng)論 1 2
  • 沒(méi)有思路客叉,寫(xiě)不出來(lái)? 思路太多话告,如何篩選兼搏? 如何搭建邏輯框架? 搭建后沙郭,又如何表達(dá)清晰形象佛呻? 領(lǐng)導(dǎo)看后,讓回去改病线,...
    信仰之躍兒閱讀 6,357評(píng)論 0 4