从命令行自动执行iOS monotouch GUI测试

时间:2012-12-12 16:25:14

标签: ios unit-testing testing xamarin.ios ios-simulator

我试图找出如何从命令行自动测试我的monotouch应用程序的GUI?我的意思是在CL中在iOS模拟器中执行GUI测试。 我发现的唯一GUI测试方法是Teleric工具,但它是not automated yet

一些提示? 感谢

2 个答案:

答案 0 :(得分:1)

如果您正在寻找可以帮助您使用TDD的内容,您可能会对葫芦感兴趣:https://github.com/calabash/calabash-ios

答案 1 :(得分:0)

您可以使用UIAutomation框架来实现自动GUI测试。它不是严格来自命令行,而是通过Instruments工具运行Javascript脚本。它与Monotouch完美配合(无论如何,我已经使用过它了)。

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

举一个脚本示例(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);
相关问题