Publish Code Coverage Results task
Azure Pipelines | Azure DevOps Server 2019 | TFS 2018 | TFS 2017 | TFS 2015
Use this task in a build pipeline to publish code coverage results produced when running tests to Azure Pipelines or TFS in order to obtain coverage reporting. The task supports popular coverage result formats such as Cobertura and JaCoCo.
Tasks such as Visual Studio Test, .NET Core, Ant, Maven, Gulp, Grunt, and Xcode also provide the option to publish code coverage data to the pipeline. If you are using these tasks, you do not need a separate Publish Test Results task in the pipeline.
# Publish Code Coverage Results # Publish Cobertura or JaCoCo code coverage results from a build - task: PublishCodeCoverageResults@1 inputs: #codeCoverageTool: 'JaCoCo' # Options: cobertura, jaCoCo summaryFileLocation: #reportDirectory: # Optional #additionalCodeCoverageFiles: # Optional #failIfCoverageEmpty: false # Optional
The codeCoverageTool and summaryFileLocation parameters are mandatory.
|Code coverage tool||(Required) The tool with which code coverage results are generated. The supported formats include Cobertura and JaCoCo.|
|Summary file||(Required) Path of the summary file containing code coverage statistics, such as line, method, and class coverage. The value may contain minimatch patterns. For example: |
|Report directory||(Optional) Path of the code coverage HTML report directory. The report directory is published for later viewing as an artifact of the build. The value may contain minimatch patterns. For example: |
|Additional files||(Optional) File path pattern specifying any additional code coverage files to be published as artifacts of the build. The value may contain minimatch patterns. For example: |
|Fail when code coverage results are missing||(Optional) Available only on Azure Pipelines and TFS 2018 and later. Fail the task if code coverage did not produce any results to publish.|
For apps using docker, build and tests may run inside the container, generating code coverage results within the container. In order to publish the results to the pipeline, the resulting artifacts should be to be made available to the Publish Code Coverage Results task. For reference you can see a similar example for publishing test results under Build, test, and publish results with a Docker file section for Docker.
In order to view the code coverage results in the pipeline, see Review code coverage results
This task is open source on GitHub. Feedback and contributions are welcome.
Q & A
I use TFS on-premises and I don't see some of these features. Why not?
Help and support
- Report problems through the Developer Community.