简体   繁体   English

Xcode 跨方案共享测试计划导致每个目标构建

[英]Xcode shared Test Plan across schemes causes each target to build

I have a simple Test Plan (with a single configuration) in my Xcode project which I am switching over to because I have multiple schemes for different app targets in my project but the tests are shared (as in they are not specifically limited to one target in terms of relevance, though only one host application was possible).我在我的 Xcode 项目中有一个简单的测试计划(具有单一配置),我正在切换到该项目,因为我的项目中有多个针对不同应用程序目标的方案,但测试是共享的(因为它们并不特别限于一个目标就相关性而言,尽管只有一个主机应用程序是可能的)。 I would like to have one Test Plan for now for all the targets, but when I created the Test Plan and added it to each scheme, and then ran the tests, I can clearly see that every target has been built.我现在想为所有目标制定一个测试计划,但是当我创建测试计划并将其添加到每个方案中,然后运行测试时,我可以清楚地看到每个目标都已构建。 The length of time it takes to build and run the tests is thus increased incrementally for each target I add.因此,对于我添加的每个目标,构建和运行测试所需的时间会逐渐增加。 The 2019 WWDC video on Test Plans clearly says they can be shared across multiple schemes but doesn't say much more than that. 2019 年 WWDC 关于测试计划的视频清楚地表明它们可以在多个方案中共享,但仅此而已。

Is this how it's supposed to behave?这是它应该表现的方式吗? Or is there a way to share a test plan between schemes but have it only build the active target that's being tested?或者有没有办法在方案之间共享测试计划,但只构建正在测试的活动目标?

EDIT: note, running tests locally as well as in automated CI, so need a solution that works for both.编辑:注意,在本地以及在自动化 CI 中运行测试,因此需要一个适用于两者的解决方案。

I'm actually not sure if it's building multiple targets because of the test plans, because only a few targets are showing in builds while there are (although it could be that Xcode is optimizing and skipping redundant building since each of the other ones is pretty much the same as one of ones that is building).由于测试计划,我实际上不确定它是否正在构建多个目标,因为只有少数目标显示在构建中(尽管可能是 Xcode 正在优化并跳过冗余构建,因为其他每个目标都很漂亮与正在建造的其中一个非常相似)。

Aha.啊哈。 It was not about Test Plans at all but rather dependencies inside the individual test bundle.它根本不是关于测试计划,而是关于单个测试包中的依赖关系。 Realized this when I went back before I switched to Test Plans and notice a couple of the targets were still building for a single test bundle.当我在切换到测试计划之前返回时意识到这一点,并注意到几个目标仍在为单个测试包构建。

Click on the scheme in Xcode project settings, go to Build Phases tab, then under dependencies check what targets are there.单击 Xcode 项目设置中的方案,go 到 Build Phases 选项卡,然后在依赖项下检查那里有哪些目标。

In my case one of my test bundles had two targets, and the other test bundle (for UI tests) had a third target.在我的例子中,我的一个测试包有两个目标,另一个测试包(用于 UI 测试)有第三个目标。

Even though my Test Plan had the UI tests disabled, I guess it was still building all the dependencies.即使我的测试计划禁用了 UI 测试,我猜它仍在构建所有依赖项。 Cleaning that up fixed the build issue I was having!清理它修复了我遇到的构建问题!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM