cocoapods库的代码覆盖率-iOS单元测试 [英] Code coverage with cocoapods library - iOS Unit Test

查看:131
本文介绍了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库的代码覆盖率-iOS单元测试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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