Combining code coverage reports from FTL and unit tests

Following up on my previous post where we saw about generating code coverage numbers for espresso tests running in FTL, this post looks at how to combine them.

This is not a new idea, I am borrowing a lot from but customizing it our CI/CD pipeline.

Assuming that your file is already created on gcloud you need to find a way fetch it down. gsutil is the most straightforward way. So I have something like this

mkdir -p app/build/test-results/Debug
mkdir -p app/build/test-results/jacoco

gsutil -m cp -r gs://${BUCKET_NAME}/**.xml app/build/test-results/Debug
gsutil -m cp -r gs://${BUCKET_NAME}/**/artifacts/ app/build/test-results/jacoco

Note: bucket name has to be unique and should be identifiable for our setup we just reuse the job name.

As a final step we have a createReports task which has jacocoPublishser like this

step([$class          : 'JacocoPublisher',
exclusionPattern: '**/R.class, **/R$*.class, **/BuildConfig.*, **/Manifest*.*, **/FakeDataLoader.*, **/Migration.*',
execPattern : "**/testEspressoEnvDebugUnitTest.exec, **/",
classPattern : "${jenkinsBuild}/build/intermediates/classes/debug/com/godaddy/gdm/telephony",
sourcePattern : '**/src/main/java'

The most important thing here is that excePattern is able to merge the file created from FTL into your jacoco report.