Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get code coverage in Xcode 6?

Tags:

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:

  • Visualizing Code Coverage with Xcode
  • Code Coverage Fixed for Xcode 5.1

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?

like image 276
cnandreu Avatar asked Sep 10 '14 20:09

cnandreu


People also ask

How do I show code coverage in Xcode?

Enabling Code Coverage in Xcode Code coverage is enabled in the scheme editor. Click the Covered scheme and choose Edit Scheme.... Select Test on the left and check the checkbox Gather coverage data. That is it.

How do I get code coverage results?

Code coverage results are displayed in the Coverage tool window, in the Project tool window, and in the editor after you run at least one configuration with coverage. Results of the code coverage analysis are saved to the coverage folder in the IDE system directory.

How does Xcode measure test coverage?

Press Cmd+9 to open the report navigator, and look for “Coverage” under the most recent test run. This will show the code coverage data that was just collected – open the disclosure indicators so you can see inside User.


1 Answers

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

like image 150
Jasper Blues Avatar answered Oct 14 '22 17:10

Jasper Blues