{"_id":"590a04f6ed80861900cbc798","__v":0,"category":{"_id":"590a04f3ed80861900cbc741","__v":0,"project":"55b2d5baa74a380d00e290c4","version":"590a04f2ed80861900cbc737","sync":{"url":"","isSync":false},"reference":false,"createdAt":"2016-07-18T21:24:18.432Z","from_sync":false,"order":10,"slug":"tests","title":"Tests (iOS)"},"parentDoc":null,"user":"55b2d5626862a10d00887af9","version":{"_id":"590a04f2ed80861900cbc737","project":"55b2d5baa74a380d00e290c4","__v":4,"createdAt":"2017-05-03T16:27:30.085Z","releaseDate":"2017-05-03T16:27:30.085Z","categories":["590a04f3ed80861900cbc738","590a04f3ed80861900cbc739","590a04f3ed80861900cbc73a","590a04f3ed80861900cbc73b","590a04f3ed80861900cbc73c","590a04f3ed80861900cbc73d","590a04f3ed80861900cbc73e","590a04f3ed80861900cbc73f","590a04f3ed80861900cbc740","590a04f3ed80861900cbc741","590a04f3ed80861900cbc742","590a04f3ed80861900cbc743","590a04f3ed80861900cbc744","590a04f3ed80861900cbc745","590a04f3ed80861900cbc746","590a04f3ed80861900cbc747","590a04f3ed80861900cbc748","590a04f3ed80861900cbc749","590a04f3ed80861900cbc74a","590a04f3ed80861900cbc74b","590a04f3ed80861900cbc74c","590a04f3ed80861900cbc74d","59124949de13f61900336a7a","5914b04e7c2c552d008b7104","5914b47242c6a22300b9dc20"],"is_deprecated":false,"is_hidden":false,"is_beta":false,"is_stable":true,"codename":"","version_clean":"7.0.0","version":"7"},"project":"55b2d5baa74a380d00e290c4","updates":[],"next":{"pages":[],"description":""},"createdAt":"2016-12-23T18:58:12.738Z","link_external":false,"link_url":"","githubsync":"","sync_unique":"","hidden":false,"api":{"results":{"codes":[]},"settings":"","auth":"required","params":[],"url":""},"isReference":false,"order":1,"body":"Code coverage measures the degree to which your code is tested by a particular test suite.\n\nWhile 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. \n\nHere’s how to enable Code Coverage for your iOS app:\n\n+ In Xcode, from the **Product** menu, choose **Scheme** and **Edit Scheme**\n+ Select the **Test** tab in the left column\n+ Toggle on the **Gather coverage data** checkbox\n\n![](https://s3-us-west-2.amazonaws.com/buddybuild-public/blog-assets/code-coverage-ios/6.png)\n\nNow that Code Coverage is enabled in Xcode, the next step is to enable Tests in buddybuild.\n\n+ First, navigate to your app in buddybuild. \n+ Next, simply click on **Settings** (the \"Gear\" icon in the header bar) and switch on **Tests**.\n\n![](https://s3-us-west-2.amazonaws.com/buddybuild-public/blog-assets/code-coverage-ios/Settings+-+Tests.png)\n\nYou'll now be presented with code coverage reports in the buddybuild dashboard (the **Coverage** column):\n\n![](https://s3-us-west-2.amazonaws.com/buddybuild-public/blog-assets/code-coverage-ios/Builds+landing+-+Coverage+column.png)\n\n\nYou can also dig into the build details by selecting the **Code Coverage** tab to see the breakdown:\n\n![](https://s3-us-west-2.amazonaws.com/buddybuild-public/blog-assets/code-coverage-ios/Builds+details+-+Code+coverage+page.png)\n\n## Want to exclude your CocoaPods dependencies from Code Coverage?\n\nYou can exclude your Pods from Code Coverage by adding the following post install script in your **Podfile**.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"post_install do |installer|\\n\\n# Disable code coverage for all Pods and Pods Project\\ninstaller.pods_project.targets.each do |target|\\n    target.build_configurations.each do |config|\\n        config.build_settings['CLANG_ENABLE_CODE_COVERAGE'] = 'NO'\\n    end\\nend\\ninstaller.pods_project.build_configurations.each do |config|\\n    config.build_settings['CLANG_ENABLE_CODE_COVERAGE'] = 'NO'\\nend\\nend\",\n      \"language\": \"shell\",\n      \"name\": \"Podfile\"\n    }\n  ]\n}\n[/block]","excerpt":"","slug":"code-coverage-ios","type":"basic","title":"Code Coverage for iOS apps"}

Code Coverage for iOS 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 iOS app: + In Xcode, from the **Product** menu, choose **Scheme** and **Edit Scheme** + Select the **Test** tab in the left column + Toggle on the **Gather coverage data** checkbox ![](https://s3-us-west-2.amazonaws.com/buddybuild-public/blog-assets/code-coverage-ios/6.png) Now that Code Coverage is enabled in Xcode, the next step is to enable Tests in buddybuild. + First, navigate to your app in buddybuild. + Next, simply click on **Settings** (the "Gear" icon in the header bar) and switch on **Tests**. ![](https://s3-us-west-2.amazonaws.com/buddybuild-public/blog-assets/code-coverage-ios/Settings+-+Tests.png) You'll now be presented with code coverage reports in the buddybuild dashboard (the **Coverage** column): ![](https://s3-us-west-2.amazonaws.com/buddybuild-public/blog-assets/code-coverage-ios/Builds+landing+-+Coverage+column.png) You can also dig into the build details by selecting the **Code Coverage** tab to see the breakdown: ![](https://s3-us-west-2.amazonaws.com/buddybuild-public/blog-assets/code-coverage-ios/Builds+details+-+Code+coverage+page.png) ## 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**. [block:code] { "codes": [ { "code": "post_install do |installer|\n\n# Disable code coverage for all Pods and Pods Project\ninstaller.pods_project.targets.each do |target|\n target.build_configurations.each do |config|\n config.build_settings['CLANG_ENABLE_CODE_COVERAGE'] = 'NO'\n end\nend\ninstaller.pods_project.build_configurations.each do |config|\n config.build_settings['CLANG_ENABLE_CODE_COVERAGE'] = 'NO'\nend\nend", "language": "shell", "name": "Podfile" } ] } [/block]