Running UIAutomation tests from Command Line

Posted in Apple, iOS, QA, Testing by AltF on February 5, 2012

Continuous Integration (CI) implements continuous processes of applying quality assurance. In the App development world, we can achieve this by automating the build and release with includes automatic trigger of smoke/functional tests and automatic deployment.

I’ve covered how to write UIAutomation tests in my previous posts (here and here) and also how to distribute stable build over the air (here). You can run your tests from command line and configure a hudson job to always deploy stable build automagically. You can run your tests from CLI using the following command.

$ instruments -t templateFilePath targetAppName

By default the tests will be executed on the simulator, you could execute the tests on actual device using the following command:

$ instruments -w deviceID -t templateFilePath targetAppName

You could execute any instruments template using command line, for example to trigger a UIAutomation template from command line you would use the command as follows:

$ instruments -t /Developer/Platforms/iPhoneOS.platform/Developer/Library/Instruments/PlugIns/AutomationInstrument.bundle/Contents/Resources/Automation.tracetemplate <path-to-your-app>/<appname>.app/ -e UIASCRIPT <path-to-your-js-test-file> -e UIARESULTSPATH <path-to-results-folder>

This is really helpful in terms of achieving CI compliance, I’ve basically written a py script that does the following:

– create a new tag from svn trunk with minor release version update
– grab the tag from svn
– complile the app from command line for xocde
– run the uiautomation smoke tests from command line (mentioned above)
– if tests are green, publish the build on the web server for OTA test distribution.
– repeat for new release

%d bloggers like this: