[iOS] デタラメな操作で自動テストしてくれる「CrashMonkey」
iOS アプリで、デタラメな操作で自動テストしてくれる「CrashMonkey」が便利だったのでご紹介します。
CrashMonkeyのインストール
gem でサクッとインストールします。
% gem install crash_monkey |
CrashMonkeyの実行方法
簡単には crash_monkey コマンドでアプリのファイル名を指定すれば、iOSシミュレータでテストが自動実行されます。
% crash_monkey -a MyApp.app |
他のオプションは、githubでご確認下さい。
CrashMonkeyがエラーで実行できないときの解決方法
最初、CrashMonkeyが下記のようなエラーで実行できませんでした。
% crash_monkey -a MyApp.app {:app_path=>"MyApp.app", :run_count=>2, :time_limit_sec=>100} =================================== Start Test (1/2) ======================================= 2 apps are found, USE NEWEST APP: /Users/bakorer/Library/Developer/Xcode/DerivedData/MyApp-dmjxyavvpzcngmeyaoznanghixim/Build/Products/Debug-iphonesimulator/MyApp.app ls: /Users/bakorer/Library/Logs/DiagnosticReports/MyApp_*.crash: No such file or directory Run: ["instruments", "-l", "100000", "-t", "/Applications/Xcode.app/Contents/Applications/Instruments.app/Contents/PlugIns/AutomationInstrument.bundle/Contents/Resources/Automation.tracetemplate", "/Users/bakorer/Library/Developer/Xcode/DerivedData/MyApp-dmjxyavvpzcngmeyaoznanghixim/Build/Products/Debug-iphonesimulator/MyApp.app", "-e", "UIASCRIPT", "/Users/bakorer/git/myapp-ios/crash_monkey_result/UIAutoMonkey.js", "-e", "UIARESULTSPATH", "/Users/bakorer/git/myapp-ios/crash_monkey_result"] xcode-select: Error: No Xcode folder is set. Run xcode-select -switch <xcode_folder_path> to set the path to the Xcode folder. Error: /usr/bin/xcode-select returned unexpected error. tail finished: system.log ls: /Users/bakorer/Library/Logs/DiagnosticReports/MyApp_*.crash: No such file or directory No matching processes belonging to you were found =================================== Start Test (2/2) ======================================= ls: /Users/bakorer/Library/Logs/DiagnosticReports/MyApp_*.crash: No such file or directory Run: ["instruments", "-l", "100000", "-t", "/Applications/Xcode.app/Contents/Applications/Instruments.app/Contents/PlugIns/AutomationInstrument.bundle/Contents/Resources/Automation.tracetemplate", "/Users/bakorer/Library/Developer/Xcode/DerivedData/MyApp-dmjxyavvpzcngmeyaoznanghixim/Build/Products/Debug-iphonesimulator/MyApp.app", "-e", "UIASCRIPT", "/Users/bakorer/git/myapp-ios/crash_monkey_result/UIAutoMonkey.js", "-e", "UIARESULTSPATH", "/Users/bakorer/git/myapp-ios/crash_monkey_result"] xcode-select: Error: No Xcode folder is set. Run xcode-select -switch <xcode_folder_path> to set the path to the Xcode folder. Error: /usr/bin/xcode-select returned unexpected error. tail finished: system.log ls: /Users/bakorer/Library/Logs/DiagnosticReports/MyApp_*.crash: No such file or directory No matching processes belonging to you were found EXIT 0 |
xcode-select コマンドで、Xcode の正しいインストールパスを指定すれば正常に動作したので、同じようなエラーが出た方は下記のコマンドを実行してみて下さい。
% sudo xcode-select -switch /Applications/Xcode.app/Contents/Developer |
まとめ
自動でテストできるので、リリース前に何回か CrashMonkey 実行して確認しておくと良いかなと思いました。
参考情報
・xcode-selectコマンドでXcodeのインストールディレクトリを変更する – Kazzzの日記
・iOS 向けモンキーテストツール CrashMonkey を公開しました (ゆめ技:ゆめみスタッフブログ)