Androidでコマンドラインから[[モンキーテスト>http://en.wikipedia.org/wiki/Monkey_test]]を行うツールmonkeyについて説明します。
#BR
*モンキーテストの実行 [#hc9e6d09]
monkeyを実行する基本構文は以下になります。
 $ adb shell monkey [options] <event-count>
#BR
具体的には以下のように実行します。
 $ adb shell monkey -v -p org.sample 100
この例ではorg.sampleパッケージの、カテゴリが Intent.CATEGORY_LAUNCHER または Intent.CATEGORY_MONKEY のアクティビティに対して、100回のイベントが実行され、結果がコンソールに出力されます。
#BR
コマンドを実行すると画面ではアクティビティが起動し、イベントが発生しているのを確認できます。また、コンソールに以下のような情報が出力されます。
 :Monkey: seed=0 count=100
 :AllowPackage: org.sample
 :IncludeCategory: android.intent.category.LAUNCHER
 :IncludeCategory: android.intent.category.MONKEY
 // 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=org.sample/.SampleActivity;end
     // Allowing start of Intent { action=android.intent.action.MAIN categories={android.inten
     t.category.LAUNCHER} comp={org.sample/org.sample.SampleActivity} } in package org.sample
 :Dropped: keys=0 pointers=0 trackballs=0 flips=0
 // Monkey finished
モンキーテスト中に例外が発生した場合は、コンソールにスタックトレースが出力されます。
#BR
*参考 [#a9259dad]
Android Developers UI/Application Exerciser Monkey:
[[http://developer.android.com/intl/ja/guide/developing/tools/monkey.html>http://developer.android.com/intl/ja/guide/developing/tools/monkey.html]]