如何在Xcode 14.3中启用代码覆盖?(它与其他版本不同)

huangapple go评论57阅读模式
英文:

How can I enable code coverage in Xcode 14.3? (It appears different from other versions)

问题

Normally I would follow these steps. Basically I would tap on my scheme, then edit, then Test, then I'd have a nice neat enable code coverage box I can tick. However, with 14.3, I don't see the info | options etc tabs, instead I see this view. And enable code coverage isn't there. Usually, it would be between Build configuration and Debugger.

14.3

如何在Xcode 14.3中启用代码覆盖?(它与其他版本不同)

Old view:
如何在Xcode 14.3中启用代码覆盖?(它与其他版本不同)

I don't see show code coverage here either:

如何在Xcode 14.3中启用代码覆盖?(它与其他版本不同)

英文:

Normally I would follow these steps. Basically I woult tap on my scheme, then edit, then Test, then I'd have a nice neat enable code coverage box I can tick. However, with 14.3, I don't see the info | options etc tabs, instead I see this view. And enable code coverage isn't there. Usually, it would be between Build configuration and Debugger.

14.3

如何在Xcode 14.3中启用代码覆盖?(它与其他版本不同)

Old view:
如何在Xcode 14.3中启用代码覆盖?(它与其他版本不同)

I don't see show code coverage here either:

如何在Xcode 14.3中启用代码覆盖?(它与其他版本不同)

答案1

得分: 13

Enabling Code Coverage has moved to Test Plan configuration which are designed to manage your tests and were introduced in Xcode 11 at WWDC 2019.

Do the following steps to enable it:

  1. 按下 Command + Option + u 打开编辑方案窗口

  2. 将鼠标悬停在自动创建的测试计划上以显示披露按钮,然后单击它。

  3. 转到配置选项卡:

  4. 查找代码覆盖并启用它:

英文:

Enabling Code Coverage has moved to Test Plan configuration which are designed to manage your tests and were introduced in Xcode 11 at WWDC 2019.

Do the following steps to enable it:

  1. Press Command + Option + u to bring the Edit Scheme window

如何在Xcode 14.3中启用代码覆盖?(它与其他版本不同)

  1. Hover over the Autocreated test plan to show the disclosure button and click it.

如何在Xcode 14.3中启用代码覆盖?(它与其他版本不同)

  1. Go to the Configuration tab :

    如何在Xcode 14.3中启用代码覆盖?(它与其他版本不同)

  2. Find Code Coverage and enable it :

如何在Xcode 14.3中启用代码覆盖?(它与其他版本不同)

答案2

得分: 5

你可以在测试计划配置中启用它。转到测试导航器。点击“测试计划”下拉菜单,然后选择“编辑测试计划”。你将能够更新测试计划的共享配置,包括代码覆盖启用:

英文:

You can enable it on the test plans configuration. Go to the Test navigator. Click on the "Test Plan" dropdown and then select "Edit test plan"

如何在Xcode 14.3中启用代码覆盖?(它与其他版本不同)

You will be able to update the shared configs of your test plans, including conde coverage enabling:
如何在Xcode 14.3中启用代码覆盖?(它与其他版本不同)

答案3

得分: 1

Edit your schema -> 编辑您的架构
Enable Code Coverage -> 启用代码覆盖
Make sure that .xctestplan has been created. -> 确保已创建.xctestplan文件。
Verify the file is in your project. -> 验证文件是否在您的项目中。
Run tests -> 运行测试

英文:

Edit your schema -> Test Plan as suggested by @Mehdi Ijadnazar more above and then:

  1. Enable Code Coverage
    如何在Xcode 14.3中启用代码覆盖?(它与其他版本不同)

  2. Make sure that .xctestplan has been created.
    如何在Xcode 14.3中启用代码覆盖?(它与其他版本不同)

  3. Verify the file is in your project.
    如何在Xcode 14.3中启用代码覆盖?(它与其他版本不同)

  4. Run tests
    如何在Xcode 14.3中启用代码覆盖?(它与其他版本不同)

答案4

得分: 0

一旦启用代码覆盖率,请检查您的文件.xctestplan是否已创建并添加到您的项目中。然后,在Xcode左侧面板的最后一个选项卡上,选择“显示报告导航器”,一旦启动您的测试,您应该会看到一个“覆盖率”行,它将为您提供所有覆盖率的访问。

xcode-screenshot-code-coverage

英文:

Once you turn on the code coverage, check that your file .xctestplan has been created and added to your project. Then on the last tab of left panel of Xcode, the 'Show the report navigator', once your test has been launched you should have a 'coverage' line that will give you access of all your coverage
xcode-screenshot-code-coverage

huangapple
  • 本文由 发表于 2023年5月7日 13:31:52
  • 转载请务必保留本文链接:https://go.coder-hub.com/76192332.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定