Code coverage for your apps

Code coverage measures the degree to which your code is tested by a particular test suite.

While your tests are executing, they exercise code paths of your app. Code coverage gives you a record of all code branches passed over by your tests and provides insight into exactly how much of your code base is being exercised during testing.

Here’s how to enable code coverage for your app:

  1. In Xcode, from the Product menu, choose Scheme → Edit Scheme.

  2. Select the Test tab in the left column.

  3. Toggle on the Gather coverage for checkbox, and specify which targets should report code coverage with the select box to the right of the checkbox.

    The Edit Scheme dialog in Xcode, with the Test panel’s Options tab selected

Now that code coverage is enabled in Xcode, the next step is to enable Tests in buddybuild.

  1. First, navigate to your app in buddybuild.

  2. Click the Settings button (the gear icon in the header bar).

  3. Click the Test toggle.

    The Tests toggle in the build settings

You’ll now be presented with code coverage reports in the buddybuild dashboard (the Coverage column):

The builds screen, with the Coverage column displayed

You can also dig into the build details by selecting the Code Coverage tab to see the breakdown:

The build details screen, with the Code Coverage tab selected

Want to exclude your CocoaPods dependencies from Code Coverage?

You can exclude your Pods from code coverage by adding the following post install script in your Podfile:

post_install do |installer|

  # Disable code coverage for all Pods and Pods Project
  installer.pods_project.targets.each do |target|
    target.build_configurations.each do |config|
      config.build_settings['CLANG_ENABLE_CODE_COVERAGE'] = 'NO'

  installer.pods_project.build_configurations.each do |config|
    config.build_settings['CLANG_ENABLE_CODE_COVERAGE'] = 'NO'

results matching ""

    No results matching ""