How to get code coverage in Xcode 6?
Asked Answered
S

3

25

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?

Swinge answered 10/9, 2014 at 20:6 Comment(6)
Find an answer to this? I'm also interested.Cule
Unfortunately no answer so far.Swinge
Have you tried to configure XCode with gcov? developer.apple.com/library/ios/qa/qa1514/_index.htmlMelbourne
It would be nice to have a minimal example of this using Travis and Coveralls.Banks
So is it just not possible with Xcode 6? I attempted to implement that outlined in your second link and no coverage files were created..Catoptrics
I've managed to get Xcode coverage to work with Xcode 6. Have a look at thisClosegrained
C
15

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

Comparative answered 12/12, 2014 at 9:3 Comment(8)
This makes things so much easier.Marcellamarcelle
Hi @Jasper the html file seems to be missing. The coverage folder is empty. Have u come across this situation before?Insensible
@Siddarthan No. Do you have latest lcov? Please raise a Github issueComparative
lcov: LCOV version 1.11 I guess this is the latest lcov. I shall raise a GitHub issueInsensible
Yup that version is all good. Does your project output coverage to custom folder (not DerivedData?). Frankencover has a cmdline arg to config that. Ok shall wait for gh issue.Comparative
That can be a reason too. Let me try that. Where can I lookup for the cmd line to config? I couldn't find it in frankencover.itInsensible
I'm trying to get this working with our project as well. We build it with CMake (using clang) but it also builds with xcode (from a project file built from the CMake project). However, when I the test program, I'm not sure what files I should be looking for in our build/test area; I'm not even sure if the code is really instrumented.Copilot
@SteveBroberg you'll know the code is instrumented if you can find *.gcda files after running tests (or the app). By default these go to DerivedData dir, though I'm not sure if cmake overrides this.Comparative
P
1

We use Xcoverage for this..Check on link below, if this helps..

Xcoverage

Poultice answered 28/10, 2014 at 20:42 Comment(0)
D
0

This is an update, From Xcode 6 Apple having in-build code coverage tool, But Have a look at coverStory it is easy to configure test locally before push. And providing a line by line coverage.

Drumm answered 18/3, 2016 at 10:19 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.