CrashMonkey

English

概要

iOSのアプリケーションをモンキーテスト(ランダムな操作をひたすら行う)するためのツールです。 動作イメージはこのデモ動画を御覧ください。 iPhone Simulatorの操作にはUIAutomationを使っていて、ベースとしてui-auto-monkeyを使わせて頂きました。

動作環境

以下の環境でのみ確認してあります。

Rubyについては、1.9系, 2.0系でも動くと思います。

CrashMonkeyの特徴

良い点

制限

Install

gem install crash_monkey --no-ri --no-rdoc

使いかた

crash_monkey -a <APP_NAME or APP_PATH>

-aでアプリの名前かPATHを指定します。

crash_monkey -a MyAwesomeApp.app                               # (1)
crash_monkey -a build/Debug-iphonesimulator/MyAwesomeApp.app   # (2)
crash_monkey -a ~/Library/Developer/Xcode/DerivedData/MyAwesomeApp-ffumcy/Build/Products/Debug-iphonesimulator/MyAwesomeApp.app # (3)

Options

% crash_monkey
Usage: crash_monkey [options]
    -a app_name                      Target Application(Required)
    -n run_count                     How many times monkeys run(default: 2)
    -d result_dir                    Where to output result(default: ./crash_monkey_result)
    -t time_limit_sec                Time limit of running(default: 100 sec)
    -c config_path                   Configuration JSON Path
    -e extend_javascript_path        Extend Uiautomation Javascript for such Login scripts
        --show-config                Show Current Configuration JSON
        --list-app                   Show List of Installed Apps in iOS Simulator
        --reset-iPhone-Simulator     Reset iPhone Simulator

-n

Monkey Testを実行する回数を指定します。

-d

結果を出力するDirを指定します。

-t

1回のテストのTimeoutを秒で指定します。

-c

UIAutomationの実行時に使うJSON形式のConfigファイルを指定します。雛形については --show-configオプションで取得してください。

-e

UIAutomation用の拡張JavaScriptファイルを指定します。 Loginなどに使うことができます。 (example)

–show-config

UIAutomationの実行時に使うConfigファイルをJSON形式で出力します。変更したい場合は、一度ファイルに保存してから変更し、 -c で指定してください。

–list-app

iPhone Simulatorにインストールされているアプリの名前の一覧を表示します。

–reset-iPhone-Simulator

iPhone Simulatorをリセットします。

Jenkinsとの連携

CrashMonkeyはコマンドラインから起動するので、JenkinsなどのCIツールと連携するのは難しくないですが、いくつか注意点を挙げておきます。

UIAutomation の 確認ダイアログがでる

そのMacで初めてCrashMonkeyを実行する場合、Instruments(UIAutomation)が確認ダイアログを表示してパスワードの入力が求められることがあります。

この場合パスワードを入力しないと実行できませんが、少なくとも以下の対処をしておけば良いです。

違う条件でも動くかもしれませんが、上記のようにしておけばダイアログが出なくなります。

ssh でログインしてこの状態になったときに、CUI上でユーザ名とパスワードを聞かれることがあります。 ここで正しく入力しても動かなかいことがありますので注意が必要です。

トラブルシューティング

xcode-select が設定されていないケース

現象

% crash_monkey -a MyGoodApp.app
.....
Run: ["instruments", "-l", "100000", "-t", ........... ]
xcode-select: Error: No Xcode folder is set. Run xcode-select -switch <xcode_folder_path> to set the path to the Xcode folder.
.....

対処

xcode-select で XcodeのInstall Pathを指定して下さい。

例)

sudo xcode-select -switch /Applications/Xcode.app/Contents/Developer

Contributing to CrashMonkey

Copyright © 2013 Ken Morishita. See LICENSE.txt for further details.