반응형
블로그 이미지
개발자로서 현장에서 일하면서 새로 접하는 기술들이나 알게된 정보 등을 정리하기 위한 블로그입니다. 운 좋게 미국에서 큰 회사들의 프로젝트에서 컬설턴트로 일하고 있어서 새로운 기술들을 접할 기회가 많이 있습니다. 미국의 IT 프로젝트에서 사용되는 툴들에 대해 많은 분들과 정보를 공유하고 싶습니다.
솔웅

최근에 올라온 글

최근에 달린 댓글

최근에 받은 트랙백

글 보관함

카테고리


반응형

UI/Application Exerciser Monkey

Monkey는 에뮬레이터나 디바이스에서 돌아가는 프로그램으로 클릭, 터치나 gesture 같은 유저 이벤트의 pseudo-random stream을 발생 시키며 system-level 이벤트들도 발생 시킨다. 여러분이 개발중인 앱의 스트레스 테스팅에 어떤 이벤트를 계속 랜덤하게 반복하는 방식으로 Monkey 를 사용할 수 있다.

Overview

Monkey는 command-line 툴이며 어떤 디바이스나 에뮬레이터에서도 실행 할 수 있다. 이 툴은 유저이벤트의 pseudo-random stream을 시스템에 전달한다. 이로서 어플리케이션에 대한 스트레스 테스트에 활용할 수 있다.

Monkey에는 여러개의 옵션이 있는데 크게 4가지로 나뉜다.

    Basic configuration options, such as setting the number of events to attempt.
    Operational constraints, such as restricting the test to a single package.
    Event types and frequencies.
    Debugging options.

Monkey가 작동중 일 때 event를 발생시키고 이것을 시스템에 전달하게 된다. 또한 테스트 중인 시스템에 대해 다음 세가지 조건들을 본다.

    If you have constrained the Monkey to run in one or more specific packages, it watches for attempts to navigate to any other packages, and blocks them.
    If your application crashes or receives any sort of unhandled exception, the Monkey will stop and report the error.
    If your application generates an application not responding error, the Monkey will stop and report the error.


여러분이 선택한 다양하고 변동적인 level에 대해 진행상황에 대한 report를 얻을 수 있다.




Basic Use of the Monkey


command line이나 script 를 이용해서 Monkey를 실행 시킬 수 있다. Monkey는 에뮬레이터와 디바이스 환경에서 작동하기 때문에 여러분의 환경에서 이것들을 shell을 통해 실행 시켜야 한다. adb shell을 이용할 수 있다. 또는 shell을 입력하던가 Monkey command를 직접 입력 할 수도 있다.

The basic syntax is:

$ adb shell monkey [options] <event-count>

아무런 옵션이 없으면 Monkey는 quiet (non-verbose) 모드로 실행 된다. 또한 테스트 앱에 있는 임의의 패키지에 이벤트를 보낼 것이다.
아래에 좀 더 구체적인 command line 이 있다. 이렇게 하면 여러분의 앱을 실행하고 500 pseudo-random event 들을 보낼 것이다.

$ adb shell monkey -p your.package.name -v 500

Command Options Reference

아래 내용들은 Monkey command line에 넣을 수 있는 옵션들이다.


Category Option Description
General --help Prints a simple usage guide.
-v Each -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.
Events -s <seed> 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.
--throttle <milliseconds> 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.
--pct-touch <percent> Adjust percentage of touch events. (Touch events are a down-up event in a single place on the screen.)
--pct-motion <percent> 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.)
--pct-trackball <percent> Adjust percentage of trackball events. (Trackball events consist of one or more random movements, sometimes followed by a click.)
--pct-nav <percent> Adjust percentage of "basic" navigation events. (Navigation events consist of up/down/left/right, as input from a directional input device.)
--pct-majornav <percent> 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.)
--pct-syskeys <percent> 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.)
--pct-appswitch <percent> 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.
--pct-anyevent <percent> 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.
Constraints -p <allowed-package-name> If you specify one or more packages this way, the Monkey will only allow 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.
-c <main-category> If you specify one or more categories this way, the Monkey will only allow 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.
Debugging --dbg-no-events When 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.
--hprof If 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. See Traceview for more information on trace files.
--ignore-crashes Normally, 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.
--ignore-timeouts Normally, 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.
--ignore-security-exceptions Normally, 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.
--kill-process-after-error Normally, 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.
--monitor-native-crashes Watches for and reports crashes occurring in the Android system native code. If --kill-process-after-error is set, the system will stop.
--wait-dbg Stops the Monkey from executing until a debugger is attached to it.



반응형