【问题标题】:UIAutomation test invocation from the command line with Xcode 6使用 Xcode 6 从命令行调用 UIAutomation 测试
【发布时间】:2014-11-11 14:23:06
【问题描述】:

从命令行运行 UIAutomation 测试似乎经常因新的 Xcode 版本而中断(从过去的帖子来看)。从未为此使用过命令行脚本,我从 2012 年发现了这篇文章:Automation Instrument from the Command Line

问题:我的命令没有错误地返回,没有输出结果,也没有任何内容记录到系统控制台。模拟器甚至没有启动!

检查一些更新路径(特别是自动化跟踪仪器路径),我想出了这个命令。注意第一个参数中的路径(它与过去的 Xcode 版本不同):

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"

gist 中选择“原始”可能会更容易阅读。

当然:

  • 我验证了为我的 .app 指定的路径确实存在;它是在成功构建和运行后产生的。
  • 我验证了在我指定的输出文件夹(“TestResults”)中,实际上没有任何记录。
  • 我验证了上述我指定的TestRunner.js 文件可以在指定的路径中找到,并成功地在自动化仪器中与仪器应用程序交互地运行。
  • 我已经检查了 Apple 的 Xcode6/iOS8 pre-release documentation(需要登录;请参阅小节标题“从命令行执行自动化仪器脚本”),没有什么不对,因为我只是针对模拟器。
我的怀疑
  • 我缺少一些标志或开关。

有人想吗?

【问题讨论】:

    标签: command-line ios8 ui-automation ios-ui-automation xcode6gm


    【解决方案1】:

    我看到了完全相同的问题,在明确提供 -w $DEVICE 参数后,我的测试终于开始了

    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
    

    【讨论】:

    • 做到了!过去的文档说它是可选的,但现在我们知道 -w 标志是强制性的。
    • 仅供参考 - 我决定“全力以赴”并组合一个 bash 脚本来运行此命令,并通过动态查找经常更改的模拟器和应用程序的相关路径来智能地执行此操作:@ 987654321@
    • 您在使用物理设备时遇到过任何问题吗?
    • 模板究竟是什么?它有什么作用? -t /Applications/Xcode6.app/Contents/Applications/Instruments.app/Contents/PlugIns/AutomationInstrument.xrplugin/Contents/Resources/Automation.tracetemplate
    猜你喜欢
    • 2014-11-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-07-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-10-07
    相关资源
    最近更新 更多