Instruments-Automation: 通过命令行运行测试用例

    为了实现自动定时的运行脚本,我们需要在命令行运行和启动脚本,具体代码如下:

instruments -t 
/Applications/Xcode.app/Contents/Applications/Instruments.app/Contents/PlugIns/AutomationInstrument.bundle/Contents/Resources/Automation.tracetemplate
<full_path_to_application> 
-e UIASCRIPT <path_to_script.js>
-e UIARESULTSPATH <output_results_path>


1.  -t 后面的参数为 Automation.tracetemplate 的路径,每个版本的位置都有所不同,在命令行下使用 instruments -s 命令进行查询。
2.  full_path_to_application 是你的的被测应用的完整目录,需要在前后加上双引号。
3.  -e UIASCRIPT  指定执行的 js 脚本存放的位置,需要在前后加上双引号。
4.  -e UIARESULTPATH  指定输出结果存放的路径,需要在前后加上双引号。

5. 如果需要在真机运行,在-t 参数前加上  -w UDID, 其中UDID为被连接手机的设备标识(可通过iTools查看)。


举例在我本地模拟器上的脚本如下:

instruments -t 
/Applications/Xcode.app/Contents/Applications/Instruments.app/Contents/PlugIns/AutomationInstrument.bundle/Contents/Resources/Automation.tracetemplate 
"/Users/wangxinxin/Library/Developer/Xcode/DerivedData/TestAutomation-ahmqgmqipyidexemazbprqxqkrya/Build/Products/Debug-iphonesimulator/TestAutomation.app" 
-e UIASCRIPT "/Users/wangxinxin/Documents/TestAutomation/test.js" 
-e UIARESULTSPATH "/Users/wangxinxin/Documents/TestAutomation"


发布了39 篇原创文章 · 获赞 10 · 访问量 6万+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章