Excluding code from coverage stats in Xcode 7

2019-01-15 05:22发布

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?

1条回答
劳资没心,怎么记你
2楼-- · 2019-01-15 05:40

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.

查看更多
登录 后发表回答