Andrej Ruman
Andrej Ruman

Reputation: 103

Execute iOS monotouch GUI tests automatically from command line

I am trying to find out how to test GUI of my monotouch app automatically from command line? I mean execute GUI tests in iOS simulator from CL. Only way of GUI testing I found was Teleric tool, but it is not automated yet

Some tips? Thanks

Upvotes: 6

Views: 287

Answers (2)

patric.schenke
patric.schenke

Reputation: 972

If you are looking for something to help you with TDD, you might be interested in calabash: https://github.com/calabash/calabash-ios

Upvotes: 1

Luke
Luke

Reputation: 3655

You can use the UIAutomation framework to achieve automated GUI tests. It's not strictly from the command line but you run Javascript scripts through the Instruments tool. It works perfectly with Monotouch (the time's I've used it, anyway).

The apple documentation on UIAutomation is pretty in depth; and hopefully should cover everything else you need.

To give an example of a script (Credit to jacksonh from Gist for this script; shamelessly taken from there).

var target = UIATarget.localTarget();
var window = UIATarget.localTarget().frontMostApp().mainWindow ();
var table = window.tableViews () [0];
var results_cell = table.cells () [0]
var run_cell = table.cells () [1];
var passed = false;
var results = '';

run_cell.tap ();

while (true) {

   target.delay (5);

    try {
        results = results_cell.name ();
    } catch (e) {
        UILogger.logDebug ('exception');
        continue;
    }

    if (results.indexOf ('failure') != -1) {
        passed = false;
        break;
    }
    if (results.indexOf ('Success!') != -1) {
        passed = true;
        break;
    }
}

UIALogger.logDebug ('Results of test run:  ' + results);
UIALogger.logDebug ('Passed:  ' + passed);

Upvotes: 0

Related Questions