我正在制作macOS单元测试包(服务器软件的集成测试):
xcodebuild -project MyApp.xcodeproj -scheme MyApp.macOS build-for-testing
结果,xcodebuild生成xctest包
MyAppTests.xctest
和xctestrun文件MyApp.xctestrun
。现在,我可以在CI服务器上部署xctest捆绑软件并执行集成测试(默认情况下旨在发布服务器软件的候选版本)。
xcodebuild test-without-building -xctestrun MyApp.xctestrun
现在我要定位另一个服务器实例(即来自开发分支)。
为此,我可以在
MyApp-development.xctestrun
键下提供另一个具有附加设置的xctestrun文件TestingEnvironmentVariables
。<key>TestingEnvironmentVariables</key>
<dict>
<key>com.myapp.ServerKind</key>
<string>development</string>
...
</dict>
在CI服务器上启动:
xcodebuild test-without-building -xctestrun MyApp-development.xctestrun
但是,维护多个xctestrun文件不是一个好主意。我想拥有
default
xctestrun文件,并从命令行覆盖它的设置。是否可以从命令行在xctestrun文件中传递其他设置(或覆盖现有设置)?
谢谢!
最佳答案
不知道它是否可以解决您的目的,但是如果我们想在目标的Build设置中覆盖类似User-Defined值的内容,则在使用xctestRun运行测试时,我没有发现直接更改它的方法。因此,我尝试在测试执行之前直接更改通过“ build-for-testing”选项创建的xctest软件包中可用的info.plist,这一切似乎正常进行。
例如。我想在不同的分区上运行测试,所以我做了defaults write <plist_file_location> PARTITION B1
这似乎可以解决问题
注意:确保<plist_file_location>
是绝对路径。提供相对路径最终将在~/Library/Preferences/Info.plist
中创建一个条目
关于macos - xcodebuild测试,无需构建。如何从命令行覆盖测试运行参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41285165/