从命令行启动Instruments [英] Start Instruments from the command line

查看:591
本文介绍了从命令行启动Instruments的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我按照这个网站开始使用UI自动化。
http://blog.manbolo .com / 2012/04/08 / ios-automated-tests-with-uiautomation#1.2



我试图从命令行启动Instruments。不幸的是,我得到一个错误:

  2013-03-14 14:06:36.376 instruments [17854:1207]设备在发射目标时丢失。中止... 
2013-03-14 14:06:36.378 instruments [17854:1207]录音已取消:至少有一个目标无法启动;中止运行
仪器跟踪错误:无法启动跟踪。

这是我使用的命令:



instruments -w {deviceId} -t /Applications/Xcode.app/Contents/Applications/Instruments.app/Contents/PlugIns/AutomationInstrument.bundle/Contents/Resources/Automation.tracetemplate {appname} -e UIASCRIPT /Path/to/Script.js



目前我使用Xcode 4.6。

  instruments -t'/Applications/Xcode.app/Contents/Applications/Instruments.app/Contents/PlugIns/AutomationInstrument.xrplugin/Contents/Resources/Automation .tracetemplate'\ 
-w'iPhone 5s'\
'/ Users / sohail / Library / Developer / CoreSimulator / Devices / 7232A640-A9D2-4626-A2AD-37AFFF706718 / data / Containers / Bundle /Application/E71B915E-051D-4BEF-9083-34416D02EC91/RoadRunnerRadar.app'\
-e UIASCRIPT'/Users/sohail/Developer/clients/acme/roadrunnerradar/ACMERoadRunnerRadarAutomationTests/TestRunner.js'\
-e UIARESULTSPATH'/ Users / sohail / Developer / clients / acme / roadrunnerradar / ACMERoadRunnerRadarAutomationTests / TestResults /'

如果您要在装置上执行这项作业,而不是上述程式码中「iPhone 5s」在模拟器上执行,您可以提供装置的UDID。然后,您可以忽略上面给出的长应用程序路径,并只提供应用程序的名称。仪器将能够在设备上找到它。



使用上面的示例,但修改了一个假设的设备,这将是:

  instruments -t'/Applications/Xcode.app/Contents/Applications/Instruments.app/Contents/PlugIns/AutomationInstrument.xrplugin/Contents/Resources/Automation .tracetemplate'\ 
-w'8532A640-A9C2-4626-A2AD-37AFFF706799'\
'RoadRunnerRadar'\
-e UIASCRIPT'/ Users / sohail / Developer / clients / acme / roadrunnerradar / ACMERoadRunnerRadarAutomationTests / TestRunner.js'\
-e UIARESULTSPATH'/ Users / sohail / Developer / clients / acme / roadrunnerradar / ACMERoadRunnerRadarAutomationTests / TestResults /'

这并未通过设备调用进行验证,因此请进行测试。



我有一个验证的 UI Automation Runner 脚本,它对Xcode 6.0.1和模拟器非常有用。


I followed this site to get started with UI Automation. http://blog.manbolo.com/2012/04/08/ios-automated-tests-with-uiautomation#1.2

I am trying to start Instruments from the command line. Unfortunately I get an error:

2013-03-14 14:06:36.376 instruments[17854:1207] Connection to the remote device lost while launching target. Aborting...
2013-03-14 14:06:36.378 instruments[17854:1207] Recording cancelled : At least one target failed to launch; aborting run
Instruments Trace Error : Failed to start trace.

This is the command I used:

instruments -w {deviceId} -t /Applications/Xcode.app/Contents/Applications/Instruments.app/Contents/PlugIns/AutomationInstrument.bundle/Contents/Resources/Automation.tracetemplate {appname} -e UIASCRIPT /Path/to/Script.js

Currently I am using Xcode 4.6.

解决方案

In 2014 with Xcode 6.0.1, you would do something like this for running UIAutomation tests on the simulator, naming your simulator after the -w switch:

instruments -t '/Applications/Xcode.app/Contents/Applications/Instruments.app/Contents/PlugIns/AutomationInstrument.xrplugin/Contents/Resources/Automation.tracetemplate' \
    -w 'iPhone 5s' \
    '/Users/sohail/Library/Developer/CoreSimulator/Devices/7232A640-A9D2-4626-A2AD-37AFFF706718/data/Containers/Bundle/Application/E71B915E-051D-4BEF-9083-34416D02EC91/RoadRunnerRadar.app' \
    -e UIASCRIPT '/Users/sohail/Developer/clients/acme/roadrunnerradar/ACMERoadRunnerRadarAutomationTests/TestRunner.js' \
    -e UIARESULTSPATH '/Users/sohail/Developer/clients/acme/roadrunnerradar/ACMERoadRunnerRadarAutomationTests/TestResults/'

If you want to run this on your device, instead of 'iPhone 5s' like I have in the snippet above for running on the simulator, you'd provide the UDID of your device. You can then omit the long app path I've given above, and just provide the name of the app. Instruments will be able to find it on the device.

Using my example from above, but modified for a hypothetical device, this would look like:

instruments -t '/Applications/Xcode.app/Contents/Applications/Instruments.app/Contents/PlugIns/AutomationInstrument.xrplugin/Contents/Resources/Automation.tracetemplate' \
    -w '8532A640-A9C2-4626-A2AD-37AFFF706799' \
    'RoadRunnerRadar' \
    -e UIASCRIPT '/Users/sohail/Developer/clients/acme/roadrunnerradar/ACMERoadRunnerRadarAutomationTests/TestRunner.js' \
    -e UIARESULTSPATH '/Users/sohail/Developer/clients/acme/roadrunnerradar/ACMERoadRunnerRadarAutomationTests/TestResults/'

This is not verified with an on device invocation, so please test it. There's a bit of flexibility with parameter ordering.

I do have a verified UI Automation Runner script that works really well for Xcode 6.0.1 and the simulator.

这篇关于从命令行启动Instruments的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆