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

And*_*man 6 testing unit-testing xamarin.ios ios ios-simulator

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

一些技巧?谢谢

Luk*_*uke 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);
Run Code Online (Sandbox Code Playgroud)