2012-12-12 39 views
6

我想了解如何從命令行自動測試我的monotouch應用程序的GUI?我的意思是在CL的iOS模擬器中執行GUI測試。 我發現的GUI測試的唯一方法是Teleric工具,但它是not automated yet從命令行自動執行iOS monotouch GUI測試

有些提示? 謝謝

+0

它必須來自命令行嗎?只要它們是一次寫入,運行多次(當然是完全自動化的),任何腳本都會執行嗎? – Luke

回答

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