从 Xcode 7 的覆盖率统计中排除代码 [英] Excluding code from coverage stats in Xcode 7

查看:38
本文介绍了从 Xcode 7 的覆盖率统计中排除代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 Xcode 7.0 和 Objective C 中启用了代码覆盖率统计(像这样)并且运行良好.

是否可以标记一些源代码行,以便覆盖率报告忽略它们?如果我使用 lcov,那么我可以使用 LCOV_EXCL_STARTLCOV_EXCL_END 标记(如 如何告诉 lcov 忽略源文件中的行)但 Xcode 无法识别这些.>

Xcode 是否有替代机制来执行此操作?

解决方案

Xcode7 及更高版本(基于在一些论坛帖子)中,覆盖系统使用 LLVM 的覆盖生成和报告机制,其格式在 http://llvm.org/docs/CoverageMappingFormat.html.从 Xcode 9 开始,此格式支持任何排除行(或其他结构)的方法.

结果映射由 llvm-导出为可使用的格式(txt 或 html)cov,它也没有太多的排除机制.llvm-cov 确实 有一些简单的阈值,仅用于报告线路和区域的大于"或小于"覆盖范围,但我怀疑根据问题,这并不完全是您所追求的

I have enabled code coverage statistics in Xcode 7.0 and Objective C (like this) and it's working well.

Is it possible to mark some source lines so that they are ignored by the coverage report? If I was using lcov then I could use LCOV_EXCL_START and LCOV_EXCL_END markers (as in How to tell lcov to ignore lines in the source files) but Xcode doesn't recognize those.

Does Xcode have an alternative mechanism for doing this?

解决方案

Xcode7 and later (based on some forum posts), the coverage system uses LLVM's coverage generation and reporting mechanisms, the format for which is detailed at http://llvm.org/docs/CoverageMappingFormat.html. As of Xcode 9, this format does not support any means of exclusion of lines (or other structures).

The resulting mapping is exported into a consumable format (txt or html) by llvm-cov, which also doesn't really have much in the way of exclusion mechanisms. llvm-cov does have some simple thresholding for only reporting on "greater than" or "less than" coverage for both lines and regions, but I suspect that's not entirely what you're after based on the question above.

这篇关于从 Xcode 7 的覆盖率统计中排除代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆