Search code examples
azure-devopssbtazure-pipelinescode-coveragejacoco

##[warning]No coverage data found. Check the build errors/warnings for more details. Azure DevOps - SBT - Jacoco


I am using sbt-jacoco to calculate code coverage and would like to publish Jacoco test coverage results in Azure DevOps test reports.

Here are my tasks:

  - script: "sbt jacoco"
    displayName: Run Jacoco

  - task: PublishCodeCoverageResults@1
    displayName: Publish code coverage report
    inputs:
      codeCoverageTool: 'JaCoCo'
      summaryFileLocation: $(System.DefaultWorkingDirectory)/target/scala-2.13/jacoco/report/html/index.html
      reportDirectory: $(System.DefaultWorkingDirectory)/target/scala-2.13/jacoco/report

These tasks are executed successfully and the results are shared as an artifact on the pipeline. However, it also throws a warning which is

##[warning]No coverage data found. Check the build errors/warnings for more details.

I would like to see the results in a chart which is attached to the pipeline. Could you please help with this problem?


Solution

  • I found the solution. I needed to adjust the configuration settings following way.

     lazy val jacoco = jacocoReportSettings in Test := JacocoReportSettings(
          "Jacoco Coverage Report",
          None,
          JacocoThresholds(instruction = 10, method = 10, branch = 10, complexity = 10, line = 10, clazz = 10),
          Seq(JacocoReportFormats.ScalaHTML, JacocoReportFormats.XML),
          "utf-8"
        )
    
      override def projectSettings: Seq[Setting[_]] = super.projectSettings ++ jacocoSettings
    

    and in Azure Pipelines it would be;

      - task: PublishCodeCoverageResults@1
        inputs:
          codeCoverageTool: 'JaCoCo'
          summaryFileLocation: $(jacocoReportDir)/report/jacoco.xml
          reportDirectory: $(jacocoReportDir)/report/html