我正在制作 macOS 单元测试包(服务器软件的集成测试):
xcodebuild -project MyApp.xcodeproj -scheme MyApp.macOS build-for-testing
Run Code Online (Sandbox Code Playgroud)
结果,xcodebuild 生成xctest包MyAppTests.xctest和xctestrun文件MyApp.xctestrun。
现在我可以在 CI 服务器上部署xctest包并执行集成测试(默认情况下针对服务器软件的发布候选版本)。
xcodebuild test-without-building -xctestrun MyApp.xctestrun
Run Code Online (Sandbox Code Playgroud)
现在我想瞄准另一个服务器实例(即来自开发分支)。
为此,我可以提供另一个xctestrun文件MyApp-development.xctestrun,其中包含 key 下的其他设置TestingEnvironmentVariables。
<key>TestingEnvironmentVariables</key>
<dict>
<key>com.myapp.ServerKind</key>
<string>development</string>
...
</dict>
Run Code Online (Sandbox Code Playgroud)
在 CI 服务器上启动:
xcodebuild test-without-building -xctestrun MyApp-development.xctestrun
Run Code Online (Sandbox Code Playgroud)
但维护多个xctestrun文件并不是一个好主意。我想要default xctestrun文件并从命令行覆盖它的设置。
是否可以从命令行传递xctestrun文件中的附加设置(或覆盖现有设置) ?
谢谢你!
小智 0
不确定它是否能解决您的目的,但如果我们想覆盖目标的构建设置中的用户定义值之类的内容,我在使用 xctestRun 运行测试时没有找到直接更改它的方法。因此,我尝试在测试执行之前直接更改使用“build-for-testing”选项创建的 xctest 包中可用的 info.plist,并且一切似乎运行良好。
例如。我想跨不同分区运行测试,所以我这样做了
defaults write <plist_file_location> PARTITION B1
这似乎可以解决问题
注意:确保<plist_file_location>是绝对路径。提供相对路径最终会在中创建一个条目~/Library/Preferences/Info.plist
| 归档时间: |
|
| 查看次数: |
7566 次 |
| 最近记录: |