Xcode 11 test Coverage report


I have successfully configured an Xcode 11 based project to build and generate a test report in Bitrise. I am able to access the test report from the build’s App & Artifacts tab as a xcode-test-results-ProjectName.html file. So far so good.

I am trying to include the Code Coverage as well, the project is configured to generate the Code Coverage report:
Scheme test action -> Options tab -> checkbox ‘Code Coverage Gather coverage…’ checked

And the ‘Xcode test for iOS’ step in Bitrise is configured to generate the code coverage files, I see this in the log file:
$ set -o pipefail && env "NSUnbufferedIO=YES" xcodebuild "-project" "/Users/vagrant/git/ProjectName.xcodeproj" "-scheme" "ProjectName" "build" "COMPILER_INDEX_STORE_ENABLE=NO" "test" "-destination" "id=CB40CADF-1FE8-47B6-9C56-1B1D2EC2A1D9" "-resultBundlePath" "/var/folders/6q/wgy6jtp12w5gzgm9lzcglpqw0000gn/T/XCUITestOutput001844682/Test.xcresult" "GCC_INSTRUMENT_PROGRAM_FLOW_ARCS=YES" "GCC_GENERATE_TEST_COVERAGE_FILES=YES" | xcpretty "--color" "--report" "html" "--output" "/Users/vagrant/deploy/xcode-test-results-ProjectName.html"

But, the resulting HTML file only produces a tests report that does not include the Coverage information we see in Xcode.

I have searched and read some discussions on this matter, but they are a bit old (2017 or earlier) so I thought I’d ask what is the current state of the art before trying something mentioned in those posts.

Is there a step or an updated article describing how to get this information in the Apps & Artifacts tab in a human readable (HTML for example) format?


I managed to get a .zip file in the Artifacts tab, including an xcov coverage report, by adding a script step right after the Xcode Test for iOS step with the following script content:

#!/usr/bin/env bash
# debug log
set -x

gem install xcov
xcov -f $BITRISE_XCRESULT_PATH -o reports
zip -r $BITRISE_DEPLOY_DIR/xcov_report.zip reports/*

The question still applies, though.

Hi @DarioGasquez! :wave: The test coverage reports are not one of the files that we automatically slate for deployment via the Deploy to Bitrise.io step, so the solution you’ve implemented here is a good approach.

Thanks for the comment Andrew.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.