Fen*_*son 22 testing xcode ios
有没有办法从代码覆盖范围中排除 Pods?
我想看看Code Coverage仅针对我编写的代码.
不是它应该重要,但我正在使用Xcode 8.
Tun*_*Fam 29
这些步骤将有助于:
1.将这些行添加到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
Run Code Online (Sandbox Code Playgroud)
2.运行pod install
现在你不会在测试覆盖范围内看到pods.
注意:它只排除了Objective-c pod而不是Swift
要禁用swift代码的覆盖,可以使用SWIFT_EXEC的包装器(到目前为止我使用Xcode 9.3验证了这一点).因此,完整的解决方案(包括Swift)将如下:
附加到您的Podfile(并pod install在之后调用):
post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |configuration|
configuration.build_settings['CLANG_ENABLE_CODE_COVERAGE'] = 'NO'
configuration.build_settings['SWIFT_EXEC'] = '$(SRCROOT)/SWIFT_EXEC-no-coverage'
end
end
end
Run Code Online (Sandbox Code Playgroud)
将以下脚本(将其命名为SWIFT_EXEC-no-coverage)放在源树的根目录(必要时为chmod + x):
#! /usr/bin/perl -w
use strict;
use Getopt::Long qw(:config pass_through);
my $profile_coverage_mapping;
GetOptions("profile-coverage-mapping" => \$profile_coverage_mapping);
exec(
"/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swiftc",
@ARGV);
Run Code Online (Sandbox Code Playgroud)
这是相应要点的链接:https://gist.github.com/grigorye/f6dfaa9f7bd9dbb192fe25a6cdb419d4
| 归档时间: |
|
| 查看次数: |
4513 次 |
| 最近记录: |