Difference in CodeCoverage result on SonarQube 6.7.5 and VSTS\TFS build summary

typescript
javascript
coverage
sonarqube
vsts

(Suraj Pardeshi) #1

Hi,

I am using SonarQube’s VSTS extensions to trigger the builds. I am building angular projects which have its respective test cases for TypeScript and JavaScript.

SonarQuber Version: 6.7.5
TFS - 2017 Update3

It display the coverage and test results on vsts successfully but displays different coverage results on sonarqube server. On VSTS/TFS build summary to display codecoverage results we have used Cobertura tool and it displays 64.46% for branches and 94.18% for lines but on SonarQube server it displays around 87.7% using lcov file and after clicking on it displays overall coverage where it displays Condition Coverage as 64.5% which is near to branch coverage displayed in VSTS summary.

So is it because we are displaying the result using different formats like Cobertura for TFS build and lcov for Sonar or there is something that i am missing in my configuration properties for sonar?
Also how can I display the test result on SonarQube which are displayed in TFS build summary?

I have attached snapshot of the same and also the additional properties that i have used in TFS build task for sonar.

Overall coverage on sonarserver

OverAll%20Coverage

Additional properties passed in Prepare Analysis Configuration task of sonar in TFS build

# Additional properties that will be passed to the scanner, **
# Put one key=value per line, example:
# sonar.exclusions=/*.bin

#sonar.javascript.lcov.reportPaths=coverage/lcov.info
#sonar.exclusions=node_modules/**
sonar.sources=src
sonar.sourceEncoding=UTF-8
sonar.exclusions=/node_modules/,/.spec.ts**
sonar.tests=src
sonar.test.inclusions=/
.spec.ts**
sonar.typescript.tslint.configpath=tslint.json
sonar.exclusions=/node_modules/,/.spec.ts,src/Tools/***
sonar.typescript.lcov.reportPaths=coverage/lcov.info
sonar.javascript.lcov.reportPaths=coverage/lcov.info
sonar.typescript.exclusions=/node_modules/,/typings.d.ts,/main.ts,/environments/environment*.ts,*/routing.module.ts

Thanks & regards,
SRP


(G Ann Campbell) #2

Hi SRP,

If you look down the column in your screenshot, you’ll see that Line Coverage is calculated at 92.8%, and Condition Coverage is at 64.5%, so pretty close to what you’re seeing in your build summary. The difference in the latter can be chalked up to rounding. The few percentage points difference in the former isn’t so easy to explain away, but may be a result of the fact that SonarQube includes in its calculations files that have no tests on them at all.

 
HTH,
Ann


(Suraj Pardeshi) #3

Okay and Is it possible to display the test results as well on SonarQube along with the Code Coverage result?


(G Ann Campbell) #4

Hi,

I’m pretty sure that was removed a while ago.

 
Ann