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

6
我正在尝试找出如何从命令行自动测试我的Monotouch应用程序的GUI?我的意思是从CL在iOS模拟器中执行GUI测试。 我发现的唯一GUI测试方法是Teleric工具,但它目前尚未自动化。 有什么建议吗? 谢谢。

它必须从命令行执行吗?只要是编写一次,多次运行(当然是完全自动化的)的脚本都可以吗? - Luke
2个回答

1

0

您可以使用UIAutomation框架来实现自动化GUI测试。虽然它不是严格意义上的命令行,但您可以通过Instruments工具运行Javascript脚本。在我使用过的时间里,它与Monotouch完美地配合。

苹果关于UIAutomation的文档非常详细,希望能涵盖您需要的所有内容。

以下是一个脚本示例(感谢Gist的jacksonh提供此脚本;我无耻地从那里拿走了它)。

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);

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接