Sonar-dotnet: C# Sensor Test Coverage Report failing to start in Main

Created on 15 May 2020  路  1Comment  路  Source: SonarSource/sonar-dotnet

Sonarqube 8.1.0.31237

I have a jenkins multi-pipeline project setup doing sonar scans with PR decoration.

When a pull request is scanned sonar correctly runs the test coverage report sensor and coverage is reported correctly.

However when this is merged back to our main the sensor just isn't being ran.

PR Branch:

....
INFO: Importing 34 Roslyn reports
INFO: Sensor C# [csharp] (done) | time=8804ms
INFO: Sensor C# Tests Coverage Report Import [csharp]
INFO: Parsing the OpenCover report C:\Jenkins\workspace\Build-API_PR-273\.\Tests\SharedDataServices.Tests\coverage.opencover.xml
....

Main Branch:

....
INFO: Importing 34 Roslyn reports
INFO: Sensor C# [csharp] (done) | time=13859ms
INFO: Sensor JavaSecuritySensor [security]
....

As you can see it completely omits the sensor.

Things I've checked:

  • Pull request works and coverage is being reported fine
  • The reports are being generated in the same relative locations on Main
  • The contents of the reports are not empty
  • The contents of the reports refer correctly to the tested .cs files

Specified step of jenkinsfile

stage("Test") 
    {
        steps 
        {
          script {

              if (env.CHANGE_ID) {
                bat 'dotnet sonarscanner begin /k:transfers-in /d:sonar.login=xxxxxxx /d:sonar.pullrequest.branch=${env.CHANGE_BRANCH} /d:sonar.pullrequest.base=${env.CHANGE_TARGET} /d:sonar.pullrequest.key=${env.CHANGE_ID} /d:sonar.cs.opencover.reportsPaths=Tests/*/coverage.opencover.xml'
              } else {
                bat 'dotnet sonarscanner begin /k:transfers-in /d:sonar.login=xxxxxxx /d:sonar.branch.name=${env.BRANCH_NAME}'
              }

              bat 'dotnet test "Build/TransfersIn.Api.sln" /p:CollectCoverage=true /p:CoverletOutputFormat=opencover'

              bat 'dotnet sonarscanner end /d:sonar.login=xxxxxxx '

          }
        }
    }

                  bat 'dotnet test "Build/TransfersIn.Api.sln" /p:CollectCoverage=true /p:CoverletOutputFormat=opencover'

                  bat 'dotnet sonarscanner end /d:sonar.login=xxxxxxx '

              }
    }
     }

Most helpful comment

Sorry guys I realised my mistake, missing /d:sonar.cs.opencover.reportsPaths=Tests/*/coverage.opencover.xml from non PR scan

>All comments

Sorry guys I realised my mistake, missing /d:sonar.cs.opencover.reportsPaths=Tests/*/coverage.opencover.xml from non PR scan

Was this page helpful?
0 / 5 - 0 ratings

Related issues

alexangas picture alexangas  路  5Comments

SasikumarJonnadula picture SasikumarJonnadula  路  4Comments

valhristov picture valhristov  路  3Comments

duncanp-sonar picture duncanp-sonar  路  5Comments

ohadschn picture ohadschn  路  3Comments