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.
The script itself can be run remotely, but we'll first need to install dependencies . .
brew install groovy brew install lcov
sudo port install groovy sudo port install lcov
NB: Xcode 7.x requires lcov 1.12, please ensure that you have this version with
Set your main App target to produce test coverage output (debug mode only).
Set your main App target to instrument program flow (debug mode only).
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.
Report file is at
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
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.
For now, the script, along with documentation is located on the gh-pages branch.
Apache License, Version 2.0, January 2004, http://www.apache.org/licenses/
- © 2014 Jasper Blues