2012-12-12 9 views
6

Próbuję dowiedzieć się, jak automatycznie przetestować GUI mojej aplikacji Monotouch z wiersza poleceń? Mam na myśli wykonanie testów GUI w symulatorze iOS z CL. Jedynym sposobem na testowanie GUI okazało się narzędzie Teleric, ale jest to not automated yetWykonywanie testów graficznych w Monotouch iOS z poziomu wiersza poleceń

Kilka porad? Dzięki

+0

Czy go musi być z linii poleceń? Czy skrypty będą działać tak długo, jak zostaną napisane raz, uruchomione wiele razy (i oczywiście w pełni zautomatyzowane)? – Luke

Odpowiedz

0

Możesz użyć struktury UIAutomation, aby uzyskać zautomatyzowane testy GUI. Nie jest to ściśle z linii poleceń, ale uruchamia skryptów JavaScript za pomocą narzędzia Instruments. Działa doskonale z Monotouch (w każdym razie w czasie, w którym go użyłem).

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

Aby dać przykład skryptu (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); 
Powiązane problemy