Here is step by step instruction on enabling code coverage in Azure DevOps
Changes in build.gradle
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 !