如何在 Xcode 6 中获得代码覆盖率?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/25774163/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 05:31:20  来源:igfitidea点击:

How to get code coverage in Xcode 6?

iosxcodecode-coveragexcode6xcode6gm

提问by cnandreu

My tests are XCTests and I'm using Objective-C instead of Swift.

我的测试是 XCTests,我使用的是 Objective-C 而不是 Swift。

I've seen some articles that tackle the topic, but the seem focused on older versions of Xcode, for example:

我看过一些解决这个话题的文章,但似乎专注于旧版本的 Xcode,例如:

What would be the recommended approach to get code coverage on Xcode 6? Does Apple have something built in for code coverage, maybe via Xcode CI via OSX Server?

在 Xcode 6 上获得代码覆盖率的推荐方法是什么?Apple 是否有内置的代码覆盖功能,也许是通过 OSX Server 的 Xcode CI?

回答by Jasper Blues

Take a look at frankencover.it

看看frankencover.it

  • Simple script that can be run from dev's cmd-line or CI build server.
  • Produces console output as well as a detailed report in HTML format. This can be viewed locally or published as an artifact by the build server.
  • Optionally includes a checker that will 'fail' the build if required coverage is not met. (Feedback only. This is a prompt to review coverage and look for useful tests that can be added orreduce the required amount. Either option may be correct. )
  • Free for both commercial and open-source projects. No hosting, sponsorship or subscription required.
  • 可以从开发人员的 cmd 行或 CI 构建服务器运行的简单脚本。
  • 生成控制台输出以及 HTML 格式的详细报告。这可以在本地查看或由构建服务器发布为工件。
  • 可选地包括一个检查器,如果不满足要求的覆盖率,它将“失败”构建。(仅反馈。这是查看覆盖率并寻找可以添加减少所需数量的有用测试的提示。任一选项都可能是正确的。)
  • 免费用于商业和开源项目。无需托管、赞助或订阅。

Usage:

用法:

FTW, it has an easy-to-remember dogue-speak-esque command line interface:

FTW,它有一个易于记忆的 dogue-speak-esque 命令行界面:

groovy http://appsquickly.github.io/frankencover.it/with --source-dir MyProject/Source

Terminal Output:

终端输出:

enter image description here

在此处输入图片说明

HTML Report:

HTML 报告:

enter image description here

在此处输入图片说明

回答by Bikramjit Singh

We use Xcoverage for this..Check on link below, if this helps..

我们为此使用 Xcoverage ..检查下面的链接,如果这有帮助..

Xcoverage

Xcoverage

回答by kaushal

This is an update, From Xcode 6 Apple having in-build code coverage tool, But Have a look at coverStory it is easy to configure test locally before push. And providing a line by line coverage.

这是一个更新,来自 Xcode 6 Apple 的内置代码覆盖工具,但是看看coverStory,在推送之前很容易在本地配置测试。并提供逐行覆盖。