Monkey Test Tool For iOS

Last update: May 25, 2022

CrashMonkey

Japanese

About

This is a tool of monkey test(random operation test) for iOS applications. Please watch the demo movie. CrashMonkey uses UIAutomation and modified ui-auto-monkey for iPhone Simulator manipulation.

Environment

It is confirmed only in the following environment.

  • Max OS X 10.8.4
  • Xcode 4.6.3(Build version 4H1503)
  • Ruby 1.8.7-p371

Ruby versions may be OK 1.9.x and 2.0.x.

Features

Good Points

  • No need to modify the app's project.
  • It can specify the running period and times.
  • The results of Screenshots and Operations history can be shown as HTML.
  • the console log and crash report can be shown.
  • It is easy to be used from CI tools like Jenkins.

Restrictions

  • It can be run only in iPhone Simulator.
  • The test can not continue when another application(like Safari) is the most front. (detect and finish the test).
  • It can not input suitable characters like ID/Pass.

Install

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

How to use

Simple Usage

crash_monkey -a <APP_NAME or APP_PATH> -w <DEVICE>

-a specify AppName or PATH. -w specify the device on which to run. A list of available devices can be obtained with crash_monkey --list-devices. In case no device is specified, it will take the first from the list.

Example

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)
  • in (1) case, an application is executed which matches the app's name installed in iPhone Simulator. If there are same name apps, the app of latest updated time is used.

  • in (2)(3) cases, an app which in the PATH is excuted. It is required that the app is built for iPhone Simlator.

Options

% crash_monkey
Usage: crash_monkey [options]
    -a app_name                      Target Application(Required)
    -w device                        Target Device(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
    --list-devices               Show List of Devices
    --reset-iPhone-Simulator     Reset iPhone Simulator

-n

The times for monkey test excution.

-d

The directory for output results.

-t

Timeout seconds for one monkey test.

-c

Specify configuration file(JSON format) for UIAutomation library. The template is shown by --show-config option.(example)

-e

Specify extend Javascript file for UIAutomation library.
It could be used for login.(example)

--show-config

Output configuration for UIAutomation library by JSON format.(example)

--list-app

List apps for iPhone Simulator.

--list-devices

List devices (simulator and attached) on which the monkey can be run.

--reset-iPhone-Simulator.

Reset iPhone Simulator.

For Jenkins

CrashMonkey has CUI interface, so easy to use from Jenkins. There are a few notes.

Confirmation dialog from UIAutomation is displayed and stop tests.

The first time in the Mac CrashMonkey run, Instruments(UIAutomation) may display a confirmation dialog and require to input password.

In this case, the test can not run if the password is not entered. The following management may be valid.

  • The Jenkins running User has Administration privilege.

  • In case Jenkins is running as slave, launch with X like following.

     javaws http://<SERVER>/computer/<NodeName>/slave-agent.jnlp
    
  • The first time a Jenkins Job runs in the Mac, if the dialog is displyed then input correct password.

Other conditions may be OK, but this is also work.

Troubleshooting

CASE: xcode-select is not set.

symptoms

% 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.
.....

measures

Please specify the install path of Xcode by xcode-select.

ex)

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

Contributing to CrashMonkey

  • Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
  • Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
  • Fork the project.
  • Start a feature/bugfix branch.
  • Commit and push until you are happy with your contribution.
  • Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
  • Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.

Copyright

Copyright (c) 2013 Ken Morishita. See LICENSE.txt for further details.

GitHub

https://github.com/mokemokechicken/CrashMonkey
Comments
  • 1. RCov does not work with Ruby 2.0. Please use simplecov.

    Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.
    
        /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby extconf.rb 
    creating Makefile
    
    make "DESTDIR="
    compiling 1.8/callsite.c
    1.8/callsite.c:2:10: fatal error: 'env.h' file not found
    #include <env.h>
             ^
    1 error generated.
    make: *** [callsite.o] Error 1
    
    
    Gem files will remain installed in /Library/Ruby/Gems/2.0.0/gems/rcov-1.0.0 for inspection.
    Results logged to /Library/Ruby/Gems/2.0.0/gems/rcov-1.0.0/ext/rcovrt/gem_make.out
    An error occurred while installing rcov (1.0.0), and Bundler cannot continue.
    Make sure that `gem install rcov -v '1.0.0'` succeeds before bundling.
    

    line16 in Gemfile should be if RUBY_VERSION > "1.9"

    Reviewed by louiseyang at 2014-03-27 11:59
  • 2. Fix for apps with spaces in path

    When the filename had a space in the path, it would not be able to find the correct folder in the DerivedData folder and it would also not find the right crash reports. This merge request should fix that.

    Reviewed by berendkleinhaneveld at 2015-09-14 12:35
  • 3. Converted example JS file to JSON file

    Crash Monkey can process a custom JSON config. However, the provided example file doesn't have the JSON format. This PR creates a new JSON file and deletes the old JS file.

    Reviewed by skrach at 2015-02-17 15:29
  • 4. change default README as English?

    • change default README as English(this repo is cool, README as english will be a good promotion )
    • add extend_javascript_path and --reset-iPhone-Simulator to README(I am sorry, I don't know Japanese)
    Reviewed by jollychang at 2014-03-12 03:31
  • 5. In latest Appium Desktop Version v1.0.0 on macOS not able to launch Android Emulator

    In latest appium Desktop Version v1.0.0 on macOS not able to launch Android Emulator if i give Desired capabilities - avd Emulator Name . .

    To successfully launch the Android Emulator i need to use Desired capabilities - avd Emulator Name . Desired capabilities - deviceName Again same Emulator Name .

    Reviewed by Nischalapp at 2017-05-03 11:06
  • 6. Some issue in monkey_runner.rb

    when i run smart_monkey -a {boundle id},it remaids me bellow,could you help me resolve it?

    sh: -c: line 0: idevicecrashreport -u AADA204E-F363-48C8-8B86-D12A308A9509 (Simulator) -e -k /Users/homeqa/smart_monkey_result/report_20170712153821/crash_1' Attempting iOS device system log capture via deviceconsole. Stop iOS system log capture. /Users/homeqa/.rvm/gems/ruby-2.4.0/gems/smart_monkey-0.5.0/lib/smart_monkey/monkey_runner.rb:201:indevice': undefined method strip' for nil:NilClass (NoMethodError) from /Users/homeqa/.rvm/gems/ruby-2.4.0/gems/smart_monkey-0.5.0/lib/smart_monkey/monkey_runner.rb:86:inblock in run_a_case' from /Users/homeqa/.rvm/gems/ruby-2.4.0/gems/smart_monkey-0.5.0/lib/smart_monkey/monkey_runner.rb:603:in watch_syslog' from /Users/homeqa/.rvm/gems/ruby-2.4.0/gems/smart_monkey-0.5.0/lib/smart_monkey/monkey_runner.rb:81:inrun_a_case' from /Users/homeqa/.rvm/gems/ruby-2.4.0/gems/smart_monkey-0.5.0/lib/smart_monkey/monkey_runner.rb:48:in block in run' from /Users/homeqa/.rvm/gems/ruby-2.4.0/gems/smart_monkey-0.5.0/lib/smart_monkey/monkey_runner.rb:45:intimes' from /Users/homeqa/.rvm/gems/ruby-2.4.0/gems/smart_monkey-0.5.0/lib/smart_monkey/monkey_runner.rb:45:in run' from /Users/homeqa/.rvm/gems/ruby-2.4.0/gems/smart_monkey-0.5.0/bin/smart_monkey:58:in<top (required)>' from /Users/homeqa/.rvm/gems/ruby-2.4.0/bin/smart_monkey:23:in load' from /Users/homeqa/.rvm/gems/ruby-2.4.0/bin/smart_monkey:23:in

    ' from /Users/homeqa/.rvm/gems/ruby-2.4.0/bin/ruby_executable_hooks:15:in eval' from /Users/homeqa/.rvm/gems/ruby-2.4.0/bin/ruby_executable_hooks:15:in
    '

    Reviewed by xuruijy at 2017-07-12 09:05
  • 7. uncaught JavaScript error: undefined is not an object (evaluating 'event.apply') on line 158 of UIAutoMonkey.js

    Error: Script threw an uncaught JavaScript error: undefined is not an object (evaluating 'event.apply') on line 158 of UIAutoMonkey.js

    I keep getting this after a few seconds of running. Also seems like the UIAutoMonkey.js has not been updated in a while.

    https://github.com/jonathanpenn/ui-auto-monkey/blob/master/UIAutoMonkey.js

    Reviewed by sagpatil at 2015-11-12 21:50
  • 8. the script is not taking any screenshots

    Hi,

    unfortunately I have the problem that script is not taking any screenshots while it is running. I start the script as it is described with:

    • crash_monkey -a /pathTo.app -w B9DECF10-E048-4823-83D5-7E34F91AFAE5
    • simulator is starting and swipes, pinches etc. are executed
    • unfortunately I con not see the "Screenshot is captured" in the console as it is described in the video below
    • when the script is running a report has been created and in the crash_monkey_result folder I can see the index.html

    but I only can see the console logs and the screenshots as it is described in the video here: https://www.youtube.com/watch?v=y5PZGVbLHtI&feature=youtu.be

    Did I missed something or is here an issue ?

    thanks for your help

    Reviewed by Tomtombulla1 at 2015-05-18 10:22
  • 9. If crashmonkey runs to different app, how can it be detected?

    Hi Mokemokechicken, I wanna ask how do you detect if the UIA runs on different app? I notice in your demo (as attached screenshot) you can detect the different app and force to stop the current instruments task. But when I tried with your version it can't detect, the UIA just hangs over there unless manually taps it back. I also traced your code but not found relative coding. Can you give a hint how did you do that? Thanks!! screen shot 2015-05-15 at 2 39 12 pm

    Reviewed by JohnnyWuMigme at 2015-05-15 06:45
Related tags
Test-To-Do-List - Test To Do List with core data
Test-To-Do-List - Test To Do List with core data

test-To-Do-List This is my first pet project with core data Launch screen Main s

Feb 26, 2022
test ios UnitTest and UITest

github_actions Bundlerの導入 fastlaneやiOSパッケージマネージャであるCocoaPodsはRubyのライブラリ 開発チームで使用するバージョンを揃えるためにBundlerを導入する bundlerのインストール gem install bundler Gemfile

Nov 3, 2021
iOS Test Hasitha

Welcome to the Bidone iOS Coding Test! iOS Create a simple application with the list of orders from viewModel and display them in a list. When a user

Nov 12, 2021
iOS Test for Openbank by David Moreno Lora
iOS Test for Openbank by David Moreno Lora

MarvelMobileTest-iOS iOS Test for Openbank by David Moreno Lora Installation Clone the project and install the dependencies using pod install Once th

Nov 16, 2021
A collection of useful test helpers designed to ease the burden of writing tests for iOS applications.
A collection of useful test helpers designed to ease the burden of writing tests for iOS applications.

MetovaTestKit is a collection of useful test helpers designed to ease the burden of writing tests for iOS applications. Requirements Installation Usag

Aug 29, 2021
iOS UI Automation Test Framework

Deprecation: EarlGrey 1.0 is deprecated in favor of EarlGrey 2.0 which integrates it with XCUITest. Please look at the earlgrey2 branch. EarlGrey 1.0

Jun 25, 2022
Alef Dev Test iOS

AlefDev тестовое задание iOS Задача Разработайте экран, где человек может заполн

Feb 25, 2022
Rapptr iOS Test Jimin Kim

Hello! Your task is to use the provided project to create the iOS app displayed

Dec 22, 2021
Mooviely - Mooviely Basic App for IOS Test

Mooviely Mooviely Basic App for IOS Test. Anasayfa Bu sayfa açıldığında ekranın

Feb 13, 2022
Stub your network requests easily! Test your apps with fake network data and custom response time, response code and headers!
Stub your network requests easily! Test your apps with fake network data and custom response time, response code and headers!

OHHTTPStubs OHHTTPStubs is a library designed to stub your network requests very easily. It can help you: test your apps with fake network data (stubb

Jun 23, 2022
BDD Framework and test runner for Swift projects and playgrounds
BDD Framework and test runner for Swift projects and playgrounds

Spectre Special Executive for Command-line Test Running and Execution. A behavior-driven development (BDD) framework and test runner for Swift project

Jun 6, 2022
The XCTest Project, A Swift core library for providing unit test support

XCTest The XCTest library is designed to provide a common framework for writing unit tests in Swift, for Swift packages and applications. This version

Jun 15, 2022
Test Library for Swift's Error Handling

CatchingFire CatchingFire is a Swift test framework, which helps making expectations against the error handling of your code. It provides for this pur

May 16, 2022
This repository accompanies Test-Driven Development in Swift: Compile Better Code with XCTest and TDD
This repository accompanies Test-Driven Development in Swift: Compile Better Code with XCTest and TDD

Apress Source Code This repository accompanies Test-Driven Development in Swift: Compile Better Code with XCTest and TDD by Gio Lodi (Apress, 2021). D

May 23, 2022
This is a simple test app getting data from network to practice a tad bit.

test This is a simple test app getting data from network to practice a tad bit. Start Nothing fancy, no CocoaPods, just clone and run! Architecture Ju

Oct 9, 2021
Test case project for mackolik

Mackolik - iOS Developer - Test Case Gökhan Mandacı 28 Oct 2021 I developed a two-page app and a general purpose drop down widget for the Mackolik Tes

Oct 28, 2021
This repo holds the code for Dubizzle & Bayut test App

DubizzleClassified This repo holds the code for Dubizzle & Bayut test App About App This is a simple app which basically fetches item list from the gi

Jun 2, 2022
Test task application based on Swift using CoreData, Alamofire, AlamofireImage and CocoaPods
Test task application based on Swift using CoreData, Alamofire, AlamofireImage and CocoaPods

iTunes Search Test task application based on Swift using CoreData, Alamofire, AlamofireImage and CocoaPods Features ?? Searching music albums by name

Oct 31, 2021
Test Technique pour LeBonCoin

Test Technique pour LeBonCoin Test Technique pour LeBonCoin Créer une application universelle (iPhone, iPad) en Swift. Celle-ci devra afficher une lis

Nov 3, 2021