Code Coverage Report (with JaCoCo) in Azure DevOps Pipeline

Vicky AV
1 min readMay 17, 2020

Here is step by step instruction on enabling code coverage in Azure DevOps

Image Taken from https://jeroenmols.com/blog/2017/11/28/coveragproblem/

Changes in build.gradle

build.gradle file

To test the configuration, try running

> ./gradlew clean build

On successful running of build task should generate following inside build directory

  • jacoco/test.exec file
  • reports/jacoco/test/jacocoTestReport.xml file
  • reports/jacoco/test/html folder

Configuring JaCoCo Code Coverage in Azure DevOps

  • Open your Azure DevOps pipeline, click Edit Pipeline (If u already have one or create a new pipeline)
  • In your Gradle task, enable the checkmark “Publish to Azure Pipelines” under JUnit Test Results
  • Add a new task “Publish code coverage results” by clicking + button
  • Under Publish code coverage result task, choose the Code Coverage Tool as JaCoCo
  • Summary file Location${System.DefaultWorkingDirectory}/**/reports/jacoco/test/jacocoTestReport.xml
  • Report Directory${System.DefaultWorkingDirectory}/**/reports/jacoco/test/html
  • Save & Queue your pipeline

Thats all folks !

--

--