#!/usr/bin/env ruby require 'commander/import' require_relative '../lib/xcmonkey' require_relative '../lib/xcmonkey/describer' require_relative '../lib/xcmonkey/repeater' require_relative '../lib/xcmonkey/logger' require_relative '../lib/xcmonkey/driver' require_relative '../lib/xcmonkey/version' class Xcmonkey program :version, VERSION program :description, 'xcmonkey is a tool for doing randomised UI testing of iOS apps' command :test do |c| c.syntax = 'xcmonkey test [options]' c.description = 'Runs monkey test' c.option('-u', '--udid STRING', String, 'Set device UDID') c.option('-b', '--bundle-id STRING', String, 'Set target bundle identifier') c.option('-e', '--event-count NUMBER', Integer, 'Set events count. Defaults to `60`') c.option('-s', '--session-path STRING', String, 'Path where test session should be saved') c.option('--throttle MILLISECONDS', Integer, 'Fixed delay between events in milliseconds. Defaults to `0`') c.option('--exclude-taps', 'Exclude taps from gestures list. Defaults to `false`') c.option('--exclude-swipes', 'Exclude swipes from gestures list. Defaults to `false`') c.option('--exclude-presses', 'Exclude presses from gestures list. Defaults to `false`') c.option('--ignore-crashes', 'Ignore app crashes. Defaults to `false`') c.option('--disable-simulator-keyboard', 'Disable simulator keyboard. Defaults to `false`') c.action do |_, options| params = { udid: options.udid, bundle_id: options.bundle_id, event_count: options.event_count, throttle: options.throttle, session_path: options.session_path, exclude_taps: options.exclude_taps, exclude_swipes: options.exclude_swipes, exclude_presses: options.exclude_presses, ignore_crashes: options.ignore_crashes, disable_simulator_keyboard: options.disable_simulator_keyboard } Xcmonkey.new(params).run end end command :repeat do |c| c.syntax = 'xcmonkey repeat [options]' c.description = 'Repeats given session' c.option('-s', '--session-path STRING', String, 'Path to monkey testing session') c.action do |_, options| params = { session_path: options.session_path } Repeater.new(params).run end end command :describe do |c| c.syntax = 'xcmonkey describe [options]' c.description = 'Describes given point' c.option('-u', '--udid STRING', String, 'Set device UDID') c.option('-x', '--x STRING', 'Point `x` coordinate') c.option('-y', '--y STRING', 'Point `y` coordinate') c.action do |_, options| params = { udid: options.udid, x: options.x, y: options.y } Describer.new(params).run end end end