通常大家的印象當中monkey都是隨機測試的工具,實際上藉助於腳本,monkey還可以完成簡單的有序的自動化測試。monkey中有一個參數
[--setup scriptfile] [-f scriptfile [-f scriptfile] ...]
可以根據下面的格式寫成腳本,在monkey中調用。例如命令行格式爲
adb shell monkey -p MY_PACKAGE --setup scriptfile -f /sdcard/ mon_script1.txt 1
count= number of events
speed= in ms
start data >>DispatchPointer(long downTime, long eventTime, int action, float x, float y, float pressure, float size, int metaState, float xPrecision, float yPrecision, int device, int edgeFlags)
DispatchTrackball same as DispatchPointer
DispatchKey(long downTime, long eventTime, int action, int code, int repeat, int metaState, int device, int scancode)
DispatchFlip(boolean keyboardOpen)
DispatchPress(int keyCode)
LaunchActivity(String pkg_name, String cl_name)
UserWait(long sleeptime)
LongPress()