ios – 无法从命令行运行UIAutomationTest

我有一个iOS应用程序,我想把它放在持续集成中.我用来做的策略是尝试从命令行运行测试.

我正在尝试使用以下脚本执行此操作:

TRACETEMPLATE="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/Library/Instruments/PlugIns/AutomationInstrument.bundle/Contents/Resources/Automation.tracetemplate"
instruments   -t $TRACETEMPLATE build/Release-iphonesimulator/MyApp.app -e UIACSCRIPT "UnitTests/SomeTest.js"

SomeTest.js是一个简单的javascript文件,我可以在Xcode中的Instrumentation中运行它可以工作.我用以下方法构建应用程序

xcodebuild -alltargets -sdk iphonesimulator5.1

这会生成MyApp.app.我可以在模拟器中从Xcode运行应用程序就好了,但是,当我尝试通过仪器运行时,我得到一个框,说有一个未知错误,并在命令行中打印:

2012-05-15 15:32:59.928 instruments[17548:1d03] Recording cancelled : At least one target failed to launch; aborting run
Instruments Trace Error : Failed to start trace.

任何人都可以给我任何关于可能发生的事情的帮助/建议,我该如何解决这个问题?

此外,它总是打开iPad模拟器?我能说它打开我想要的任何模拟器吗?

解决方法

我得到了同样的错误,差点把我的头发拉出来试图解决它.错误消息完全没有用.

最终成为问题的是我指向的.app文件.一旦我找到了深深埋藏在5.1 Simulator文件夹中的“正确”.app文件,我终于能够通过Xcode 4.3从命令行运行UIAutomation测试.

.app的路径对我有用:

~/Library/Application Support/iPhone Simulator/5.1/Applications/{string-of-numbers-and-letters}/MyApp.app/

这是我用来从Xcode 4.3命令行运行UIAutomation测试的完整命令:

instruments -t /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/Library/Instruments/PlugIns/AutomationInstrument.bundle/Contents/Resources/Automation.tracetemplate ~/Library/Application Support/iPhone Simulator/5.1/Applications/{string-of-numbers-and-letters}/MyApp.app/ -e UIASCRIPT /Path/To/TestFile.js

希望这可以帮助其他人,因为那里的文档非常缺乏.

更新

请注意,从Xcode 4.5.2开始,自动化模板位置与原始答案的位置有所不同:

/Applications/Xcode.app/Contents/Applications/Instruments.app/Contents/PlugIns/AutomationInstrument.bundle/Contents/Resources/Automation.tracetemplate

以上是来客网为你收集整理的ios – 无法从命令行运行UIAutomationTest全部内容,希望文章能够帮你解决ios – 无法从命令行运行UIAutomationTest所遇到的程序开发问题。

如果觉得来客网网站内容还不错,欢迎将来客网网站推荐给程序员好友。