I'm making macOS unit testing bundle (integration test for server software):
xcodebuild -project MyApp.xcodeproj -scheme MyApp.macOS build-for-testing
As result, xcodebuild generates xctest bundle MyAppTests.xctest
and xctestrun file MyApp.xctestrun
.
Now I can deploy xctest bundle on CI server and execute integration tests (by default targeted to release candidate version of server software).
xcodebuild test-without-building -xctestrun MyApp.xctestrun
Now I want to target another server instance (i.e. from development branch).
For doing this I can provide another xctestrun file MyApp-development.xctestrun
with additional settings under TestingEnvironmentVariables
key.
<key>TestingEnvironmentVariables</key>
<dict>
<key>com.myapp.ServerKind</key>
<string>development</string>
...
</dict>
Launch on CI server:
xcodebuild test-without-building -xctestrun MyApp-development.xctestrun
But maintaining several xctestrun files is not a good idea. I want to have default
xctestrun file and override it's settings from command line.
Is it possible to pass additional settings (or override existing settings) in xctestrun file from command line?
Thank you!
Not sure if it solves your purpose, but if we wanted to override something like a User-Defined values in the Build settings of the target, i didn't find a straight forward to alter it while running test using xctestRun. So I tried directly altering the info.plist thats available inside the xctest bundle created with "build-for-testing" option before test execution and things seems to work well.
For eg. I wanted to run the test across different partitions, so i did
defaults write <plist_file_location> PARTITION B1
and this seems to do the trick
Note : Make sure
<plist_file_location>
is an absolute path. Providing relative path would end up creating an entry in~/Library/Preferences/Info.plist