使用 xcodebuild 将参数传递给 iOS 测试 [英] Passing arguments to iOS tests with xcodebuild

查看:41
本文介绍了使用 xcodebuild 将参数传递给 iOS 测试的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想通过命令行 (xcodebuild) 将命令行参数传递给我的 iOS 测试.我正在 XCode 上寻找与此设置等效的内容:

简单地将参数传递给 xcodebuild 是行不通的,例如:

xcodebuild -verbose test -workspace theworkspace.xcworkspace -scheme 'thescheme' -destination 'platform=iOS Simulator,name=iPhone 7' --argument=value

这个问题类似于 xcodebuild 将参数传递给 iOS 上的应用程序 但这个问题的解决方案并不令人满意.

解决方案

我没能找到简单"的解决方案.因此,我将测试分为 3 个步骤:
1. 运行 xcodebuild build-for-testing.它将在派生数据中生成 xctestrun 文件,其中包含启动参数列表
2.在此处添加您想要的启动参数
3. 运行 xcodebuild test-without-building -xctestrun <%path_to_file_here%>

我为它写了脚本.它仍然需要一些改进,所以在不久的将来我会分享它的最终形式.

从来没有时间更新脚本.所以这里有丑陋的版本,适合我们的需求.https://gist.github.com/ManWithBear/57cbabc8dcd0193d156c376d

I'd like to pass command line arguments to my iOS tests through the command line (xcodebuild). I'm looking for the equivalent of this setting on XCode:

Simply passing the argument to xcodebuild doesn't work, e.g.:

xcodebuild -verbose test -workspace theworkspace.xcworkspace -scheme 'thescheme' -destination 'platform=iOS Simulator,name=iPhone 7' --argument=value

This question is similar to xcodebuild pass arguments to application on iOS but the solution to that question is not satisfactory.

解决方案

I didn't manage to find "easy" solution. So instead I split testing in 3 steps:
1. Run xcodebuild build-for-testing. It will generate xctestrun file in derived data, which contains list of launch arguments
2. Add your desire launch arguments here
3. run xcodebuild test-without-building -xctestrun <%path_to_file_here%>

I wrote script for it. It still need some improvements, so in close time I will share its final form.

Edit: Never had time to update script. So here ugly versions, that suit our needs. https://gist.github.com/ManWithBear/57cbabc8dcd0193d156c376d2d23ff02

这篇关于使用 xcodebuild 将参数传递给 iOS 测试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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