Producing a test coverage report for iOS and OSX projects requires a mish-mash of tools and steps. Here we've glued them all together into something that (hopefully) just works.

  • Generates a report with minimal steps.
  • Outputs to the terminal as well as produces a detailed report in build-server friendly HTML format.
  • Includes a coverage checker. This can be used in CI builds to check minimum test coverage - failing the build if coverage falls below the required amount.
  • Free for both commercial and open-source projects.

#Installing

The script itself can be run remotely, but we'll first need to install dependencies . .

With HomeBrew

brew install groovy
brew install lcov

With MacPorts

sudo port install groovy
sudo port install lcov

NB: Xcode 7.x requires lcov 1.12, please ensure that you have this version with lcov --version

#Usage

Set your main App target to produce test coverage output (debug mode only).

Enable Coverage

Set your main App target to instrument program flow (debug mode only).

Enable Instrumentation

IDE Use

Run tests in your IDE (AppCode or Xcode) and produce a report with:

groovy http://frankencover.it/with -source-dir MyProject/Source

Build server or cmd-line use

Create a build script as follows

# First Run Tests
xcodebuild test -workspace MyProject.xcworkspace/ -scheme 'MyProject' -configuration Debug \
-destination 'platform=iOS Simulator,name=iPhone 5s,OS=8.1' | xcpretty -c --report junit
#Above we are piping the build output through xcpretty, which is not required, but very nice. 
#(gem install xcpretty)

# Now Produce Test Coverage Report
groovy http://frankencover.it/with -source-dir MyProject/Source -required-coverage 85
#Above we set required coverage to 85%. Build fails if coverage falls below this value. 

. . this ensures using an update to date version.

Output

cmd-line

Output

browser

Report file is at build/reports/coverage/index.html.

Browser

Cobertura Format

If you'd like to publish in Cobertura format (commonly supported by build servers) we recommend this Python script.

Place the script somewhere on visible to your build server or whatever needs cobertura format, and then execute as follows:

python ~/lcov_cobertura.py build/reports/coverage/data/coverage.info

Install locally

If you don't want to run the hosted script, it can be installed locally with:

curl -SSL http://frankencover.it/with > FrankenCover && chmod +x ./FrankenCover

Swift Code Coverage

At the present time Swift Code coverage because the compiler currently ignores instructions to instrument the codebase. Please vote for this OpenRadar issue.

Like this project?

frankencover.it is a non-profit, community driven project. We only ask that if you've found it useful to star us on Github or send a tweet mentioning us (@appsquickly). frankencover.it is sponsored and lead by appsquick.ly, with contributions from around the world.

A big thank you to the following contributors:

  • Alex Argo : Feedback & fixes for directories with unusual characters
  • Hybrid Cat : Exclusions, html report configs.

Contributing

For now, the script, along with documentation is located on the gh-pages branch.

LICENSE

Apache License, Version 2.0, January 2004, http://www.apache.org/licenses/

  • © 2014 Jasper Blues


制作iOS和OSX项目的测试报告报告需要一些混合的工具和步骤。在这里,我们把它们整合在一起(希望)只是起作用。

  • 以最少的步骤生成报表。
  • 输出到终端,并以构建服务器友好的HTML格式生成详细报告。
  • 包括覆盖检查器。这可以在CI构建中用于检查最低测试覆盖率 - 如果覆盖率低于所需量,则构建失败。
  • 免费为商业和开源项目。

#安装

脚本本身可以远程运行,但是我们首先需要安装依赖关系。 。

使用HomeBrew

brew install groovy
brew install lcov

使用MacPorts

sudo port install groovy
sudo port install lcov
注意: Xcode 7.x需要lcov 1.12,请确保您具有此版本的 lcov –version

#Usage

设置您的主要应用程序目标,以产生测试覆盖输出(仅限调试模式)。

启用覆盖data-canonical-src

将您的主要应用程序目标设置为仪器程序流程(仅适用于调试模式)。

启用仪器data-canonical-src

IDE使用

在您的IDE(AppCode或Xcode)中运行测试并生成一个报告:

groovy http://frankencover.it/with -source-dir MyProject/Source

构建服务器或cmd行使用

如下创建构建脚本

# First Run Tests
xcodebuild test -workspace MyProject.xcworkspace/ -scheme 'MyProject' -configuration Debug 
-destination 'platform=iOS Simulator,name=iPhone 5s,OS=8.1' | xcpretty -c –report junit #Above we are piping the build output through xcpretty, which is not required, but very nice. #(gem install xcpretty)

# Now Produce Test Coverage Report groovy http://frankencover.it/with -source-dir MyProject/Source -required-coverage 85 #Above we set required coverage to 85%. Build fails if coverage falls below this value.

。 。这将确保使用更新到最新版本。

Output

cmd-line

输出data-canonical-src

browser

报告文件位于 build / reports / coverage / index.html

浏览器data-canonical-src

Cobertura Format

如果您想以Cobertura格式发布(通常由构建服务器支持),我们建议您此Python脚本< / a>。

将脚本放置在可见的位置到构建服务器或任何需要的cobertura格式,然后执行如下:

python ~/lcov_cobertura.py build/reports/coverage/data/coverage.info

Install locally

如果您不想运行托管脚本,可以在本地安装:

curl -SSL http://frankencover.it/with > FrankenCover && chmod +x ./FrankenCover

Swift Code Coverage

目前Swift Code的覆盖范围是因为编译器当前忽略了对代码库的指令。请投票支持此OpenRadar问题。

Like this project?

frankencover.it是一个非营利性社区驱动型项目。我们只会问,如果您发现在Github上给我们打个招呼或者发短信提到我们( @appsquickly )。 frankencover.it由来自世界各地的贡献的 appsquick.ly 赞助并领导。

很感谢以下贡献者:

  • Alex Argo :反馈&amp;修复具有不寻常字符的目录
  • 混合猫:排除,html报告配置。

贡献

现在,脚本以及文档位于gh-pages分支上。

LICENSE

Apache许可证版本2.0,2004年1月, http://www.apache.org/licenses/

  • ©2014 Jasper Blues




相关问题推荐