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è)試”
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)完成