UIAutomation test invocation from the command line with Xcode 6

泪湿孤枕 提交于 2019-12-10 07:16:54

问题


Running UIAutomation tests from the command line seems to break often with new Xcode releases (judging by past posts). Having never used the command line scripting for this, I found this post from 2012: Automation Instrument from the Command Line.

The Problem: My command returns without error, without output results and without anything logged to the system console. The simulator does not even launch!

Checking some of the paths for updates (notably, the Automation trace instrument path), I came up with this command. Note the path in the first parameter (it's different than in past Xcode releases):

instruments -t "/Applications/Xcode.app/Contents/Applications/Instruments.app/Contents/PlugIns/AutomationInstrument.xrplugin/Contents/Resources/Automation.tracetemplate"         
"/Users/sohail/Library/Developer/CoreSimulator/Devices/7232A640-A9D2-4626-A2AD-37AFFF706718/data/Containers/Bundle/Application/D07FEC4B-76AD-4844-8362-08E771B81053/MyAppName.app"
-e UIASCRIPT  "/Users/sohail/source/MyAppName/MyAppNameAutomationTests/TestRunner.js" 
-e UIARESULTSPATH "Users/sohail/source/MyAppName/MyAppNameAutomationTests/TestResults"

This might be easier to read by selecting "raw" from this gist.

Of course:

  • I validated that the path specified to my .app actually exists; it came into being after a successful build and run.
  • I validated that in my specified output folder ("TestResults") that in fact, nothing got logged.
  • I validated that the aforementioned TestRunner.js file I specified, could be found at the path specified, and successfully runs in the Automation Instrument interactively with the Instruments app.
  • I've checked Apple's Xcode6/iOS8 pre-release documentation (login required; see section title, "Executing an Automation Instrument Script from the Command Line"), and nothing jumps out at me as wrong, since I'm just targeting the simulator.
My suspicion
  • I'm missing some flag or switch somewhere.

Thoughts anyone?


回答1:


I saw the exact same issue, after explicitly provided -w $DEVICE parameter, my tests finally got started

instruments -t /Applications/Xcode6.app/Contents/Applications/Instruments.app/Contents/PlugIns/AutomationInstrument.xrplugin/Contents/Resources/Automation.tracetemplate 
-w "iPhone 5s (8.0 Simulator)" /path/to/my/TestApp.app -e UIASCRIPT /tmp/script.js -e UIARESULTSPATH /tmp


来源:https://stackoverflow.com/questions/25892427/uiautomation-test-invocation-from-the-command-line-with-xcode-6

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!