Test: Publish Code Coverage Results

VSTS | TFS 2018 | TFS 2017 | TFS 2015

icon Publishes code coverage results that were produced by a build in Cobertura or JaCoCo format.

YAML snippet

# Publish Code Coverage Results
# Publish Cobertura or JaCoCo code coverage results from a build
- task: PublishCodeCoverageResults@1
    #codeCoverageTool: 'JaCoCo' # Options: cobertura, jaCoCo
    #reportDirectory: # Optional
    #additionalCodeCoverageFiles: # Optional
    #failIfCoverageEmpty: false # Optional


Code coverage tool(Required) The tool with which code coverage results are generated.
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: $(System.DefaultWorkingDirectory)/MyApp/**/site/cobertura/coverage.xml
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: $(System.DefaultWorkingDirectory)/MyApp/**/site/cobertura
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: $(System.DefaultWorkingDirectory)/**/*.exec
Fail when code coverage results are missing(Optional) Available only on VSTS and TFS 2018 and later. Fail the task if code coverage did not produce any results to publish.
Control options

More Information

Open source

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?

Some of these features are available only on VSTS and not yet available on-premises. Some features are available on-premises if you have upgraded to the latest version of TFS.

Help and support