OUR BLOG

Thoughts on development, design and the world we live in.



Show Test Coverage in Xcode

By paul in iOS, iPad, iPhone, Objective-c, Test Driven Development. Posted on June 29th

There is CoverStory - an open source utility that can show you test coverage for your XCode unit tests.

The problem is that CoverStory requires you to pick correct directory where object files and coverage metrics are stored. The directory could change from time to time.

If you add this osascript as post test action in your scheme the CoverStory will open automatically.
To do that select Product->Edit Scheme in Xcode menu. When the drawer opens expand Test and select Post-actions. Click on (+) and pick “New Run Script Action” from the drop-down.
Set Shell to

Set “Provide your build settings from:” drop-down to your test bundle, which is called Unit Specs in our case.
And copy and paste this code:

Here is the screenshot (click to enlarge):


To enable test coverage measurements in your project, you have to set the following build Settings on your test target:

If your Xcode test target fails with the following error:

Then you can add this workaround for missing symbol:

Try it out, let us know how it worked for you.

One Comment

  1. Posted July 11, 2012 at 3:45 am | Permalink

    Sweet addition. Now I don’t have to indicate each time the directory =)

Post a Comment

Your email is never shared. Required fields are marked *

*
*