英文:
xcodebuild ignores testPlan when using test-without-building
问题
考虑这个示例项目:https://github.com/stremsdoerfer/TestPlan。这只是一个Hello World,有两个测试计划:TestPlanUnit
仅运行单元测试,TestPlanUI
仅运行 UI 测试。
在使用 Xcode 14.3 运行以下命令时,我期望运行 TestPlanUI
,但实际上只运行了默认的 TestPlanUnit
。
xcodebuild -scheme TestPlan -destination 'platform=iOS Simulator,id=<sim_id>' -testPlan TestPlanUI test-without-building
在 Xcode 14.2 中正常工作。
使用 test
而不是 test-without-building
也正常工作。
有什么想法?
英文:
Consider this sample project: https://github.com/stremsdoerfer/TestPlan. This is just a Hello World that has two test plans: TestPlanUnit
that only runs unit tests and TestPlanUI
that only run UI tests.
Running the command below with Xcode 14.3, I'd expect TestPlanUI
to be run, but instead only TestPlanUnit
is run which is the default.
xcodebuild -scheme TestPlan -destination 'platform=iOS Simulator,id=<sim_id>' -testPlan TestPlanUI test-without-building
It works fine with Xcode 14.2.
Using test
instead of test-without-building
also works fine.
Any thoughts?
答案1
得分: 3
报告了相同的问题给苹果。当传递 test-without-building
时,似乎会忽略 testPlan
参数。
英文:
Having the same problem and reported an issue to Apple. The testPlan
parameter seems to be ignored when test-without-building
is passed.
答案2
得分: 3
我也向苹果报告了testPlan ignored when using xcodebuild test-without-building
。苹果回应:已经确定潜在修复方法 - 会在未来的操作系统更新中解决
。
英文:
I also reported testPlan ignored when using xcodebuild test-without-building
to Apple.
Apple responded with: Potential fix identified - For a future OS update
.
答案3
得分: 2
不是解决方案,但在Apple修复之前可能的解决方法。如果复制你的Scheme,然后将该Scheme的默认TestPlan设置为你想要运行的测试,test-without-building将会关注Scheme中的默认测试。
我已经使用fastlane
和直接使用xcodebuild
进行了测试,都可以按这种方式工作。我不是很喜欢这种方法,特别是因为我的Schemes相当复杂。然而,我成功地让我的测试运行了。
确保你的运行变体都已构建。我遇到了一个问题,之前复制了我的Schemes,其中一个Scheme的运行 / 诊断设置与一个TestPlan的_运行时Sanitization_不同。因此,当我在关闭Sanitization的情况下在CI中运行测试时,该Scheme希望在Variant-NoSanitizers
中有一个二进制文件。
英文:
Not a solution, but a potential work-around until Apple fixes it. If you make a copy of your Scheme and then set the default TestPlan for that Scheme to be the test you want to run, test-without-building will pay attention to the default test in the Scheme.
I've tested with fastlane
and directly using xcodebuild
and both worked this way. I don't love it, especially because my schemes are fairly complex. However, I did have success getting my tests to run.
Make sure your Run variants are all built. I ran into a problem where I'd copied my schemes a while back and one scheme diverged by the Run / Diagnostics settings for the Runtime Sanitization for a single TestPlan. As such, that scheme wanted a binary in the Variant-NoSanitizers
when I ran my tests in CI with sanitization turned off.
答案4
得分: 1
I got a working soloution that does not require any hacks 🔥
The first invocation of xcodebuild
will create a xctestrun
file:
xcrun xcodebuild build-for-testing -workspace <project_root>/<project_name>.xcworkspace -scheme <scheme> -destination 'platform=iOS Simulator,id=2253C0D7-C198-44AD-A98B-11301FD88F30'
This file will be located in the DerivedData folder and be named like this:
~/Library/Developer/Xcode/DerivedData/<build_folder>/Build/Products/<scheme>_<test_plan_name>_<device_type><ios-version>-<architecture>.xctestrun
An example would be MyScheme_Screenshots_iphonesimulator16.4-arm64.xctestrun
The second invocation of xcodebuild
then uses this file to run the tests. It is not allowed to specify any of [-project, -scheme, -workspace]
when using -xctestrun
:
xcrun xcodebuild test-without-building -destination 'platform=iOS Simulator,id=2253C0D7-C198-44AD-A98B-11301FD88F30' -xctestrun ~/Library/Developer/Xcode/DerivedData/<build_folder>/Build/Products/<scheme>_<test_plan_name>_<device_type><ios-version>-<architecture>.xctestrun
Hope this helps you folks 👍
PS: Here you can find the Pull Request for my command line tool Snap
that integrates this fix. Snap creates screenshots using Xcode TestPlans. Super useful for CI 🔥
英文:
Actually I got a working soloution that does not require any hacks 🔥
The first invocation of xcodebuild
will create a xctestrun
file:
xcrun xcodebuild build-for-testing -workspace <project_root>/<project_name>.xcworkspace -scheme <scheme> -destination 'platform=iOS Simulator,id=2253C0D7-C198-44AD-A98B-11301FD88F30'
This file will be located in the DerivedData folder and be named like this:
~/Library/Developer/Xcode/DerivedData/<build_folder>/Build/Products/<scheme>_<test_plan_name>_<device_type><ios-version>-<architecture>.xctestrun
An example would be MyScheme_Screenshots_iphonesimulator16.4-arm64.xctestrun
The second invocation of xcodebuild
then uses this file to run the tests. It is not allowed to specify any of [-project, -scheme, -workspace]
when using -xctestrun
:
xcrun xcodebuild test-without-building -destination 'platform=iOS Simulator,id=2253C0D7-C198-44AD-A98B-11301FD88F30' -xctestrun ~/Library/Developer/Xcode/DerivedData/<build_folder>/Build/Products/<scheme>_<test_plan_name>_<device_type><ios-version>-<architecture>.xctestrun
Hope this helps you folks 👍
PS: Here you can find the Pull Request for my command line tool Snap
that integrates this fix. Snap creates screenshots using Xcode TestPlans. Super useful for CI 🔥
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论