cocoapods库的代码覆盖率

编程入门 行业动态 更新时间:2024-10-19 08:45:20
本文介绍了cocoapods库的代码覆盖率-iOS单元测试的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

在Xcode 7中,cocoapods库包含代码覆盖范围的排除项。

In Xcode 7, the library for cocoapods library with exclude for the code coverage.

但是在Xcode 8中,该库将包含代码覆盖范围。

But In Xcode 8, the library will include for code coverage.

我是否可以在代码覆盖范围内排除该库?

Can I had anyway to exclude the library in the code coverage?

示例:安装pod'TPKeyboardAvoiding ' TPKeyboardAvoidingScrollView.m包含在代码覆盖范围内。

Example: Install pod 'TPKeyboardAvoiding' TPKeyboardAvoidingScrollView.m is include in the code coverage.

推荐答案

您应禁用目标代码覆盖范围你不想被覆盖。如果您不希望所有Pod都包含在代码覆盖范围内,则可以在Podfile中添加

You should disable the Code Coverage for the Targets that you don't want to be covered. If you want all of your pods to not be included in the code coverage you can add on your podfile

# Disable Code Coverage for Pods projects post_install do |installer_representation| installer_representation.pods_project.targets.each do |target| target.build_configurations.each do |config| config.build_settings['CLANG_ENABLE_CODE_COVERAGE'] = 'NO' end end end

这将禁用Pod目标的代码覆盖率,如这张图片

This will disable the Code Coverage for the target of your Pods like in this image

如果您现在使用 command + U

我在我的一个项目中尝试使用此吊舱,它对我有用。我正在使用Xcode版本8.1(8B62)

I tried with this pod in one of my project and it worked for me. I'm using Xcode Version 8.1 (8B62)

无论如何,我仍在为地图。有一个特殊的设置(我尚未发现),它似乎覆盖了 CLANG_ENABLE_CODE_COVERAGE ,并且测试仍然会为此生成代码覆盖率。

Anyway, I'm still struggling with the same issue for other pods like Cartography. There's a particular setting (which I didn't discover yet) that it seems to override the CLANG_ENABLE_CODE_COVERAGE and the tests still produces the Code Coverage for that.

让我知道这是否可以解决您的问题。

Let me know if this solve your issue.

更多推荐

cocoapods库的代码覆盖率

本文发布于:2023-11-16 01:40:10,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1599837.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:覆盖率   代码   cocoapods

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!