How to get code coverage in Xcode 6?

cnandreu picture cnandreu · Sep 10, 2014 · Viewed 8.8k times · Source

My tests are XCTests and I'm using Objective-C instead of Swift.

I've seen some articles that tackle the topic, but the seem focused on older versions of Xcode, for example:

What would be the recommended approach to get code coverage on Xcode 6? Does Apple have something built in for code coverage, maybe via Xcode CI via OSX Server?

Answer

Jasper Blues picture Jasper Blues · Dec 12, 2014

Take a look at frankencover.it

  • Simple script that can be run from dev's cmd-line or CI build server.
  • Produces console output as well as a detailed report in HTML format. This can be viewed locally or published as an artifact by the build server.
  • Optionally includes a checker that will 'fail' the build if required coverage is not met. (Feedback only. This is a prompt to review coverage and look for useful tests that can be added or reduce the required amount. Either option may be correct. )
  • Free for both commercial and open-source projects. No hosting, sponsorship or subscription required.

Usage:

FTW, it has an easy-to-remember dogue-speak-esque command line interface:

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

Terminal Output:

enter image description here

HTML Report:

enter image description here