CoverStory and Code Coverage

One of the questions that will arise once you start really using unit testing is “How much of my code is actually tested?”. iOS and CoverStory make determining this fairly simple.

During compile, setting the profile-arcs and test-coverage flags and including the libprofile_rt.dylib causes the compiler to generate gcov records that report statistics about test coverage.

CoverStory can then be used to display the information from those records. Refer to the instructions for CoverStory for details on how to download, install, and run CoverStory.

Now I need to investigate how to make this work when using GHUnit…

One thought on “CoverStory and Code Coverage

  1. Note: I retested this on Xcode 4.6.2 and it is easier now. All that is needed to collect the code coverage reports is the set 2 flags in the product target build settings (under the Code Generation section):
    1. “Generate Test Coverage Files”
    2. “Instrument Program Flow”
    Then open CoverStory and navigate to the derived data (from Organizer -> Projects) -> Build -> Intermediates -> .build -> Debug-iphonesimulator -> .build -> Objects-normal -> i386.

Leave a Reply