【问题标题】:Execute iOS monotouch GUI tests automatically from command line从命令行自动执行 iOS monotouch GUI 测试
【发布时间】:2012-11-30 09:57:10
【问题描述】:

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

一些提示? 谢谢

【问题讨论】:

  • 是否必须来自命令行?只要编写一次,运行多次(当然是完全自动化的),任何脚本都会这样做吗?

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


【解决方案1】:

如果您正在寻找对 TDD 有帮助的东西,您可能会对葫芦感兴趣:https://github.com/calabash/calabash-ios

【讨论】:

    【解决方案2】:

    您可以使用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);
    

    【讨论】:

      猜你喜欢
      • 2011-01-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-10-30
      • 2014-03-20
      • 2013-12-12
      • 2010-10-07
      • 1970-01-01
      相关资源
      最近更新 更多