SonarQube Code Coverage Shows 0 While Using Ubuntu agents in Azure Devops

Template for a good bug report, formatted with Markdown:

  • versions used (SonarQube, Scanner, Plugin, and any relevant extension) : * Community Edition Version 7.9.1 (build 27448)
  • error observed (wrap logs/code around triple quote ``` for proper formatting)
  • steps to reproduce
  • potential workaround
    Hi Team

We are facing multiple times code coverage as 0 for all the ubuntu agents hosted on azure devops .
Parameters mentioned in the coverage are “/d:sonar.cs.vscoveragexml.reportsPaths=”*.coveragexml"
/d:sonar.cpd.exclusions="
/*test.cs" "
Please check and suggest what needs to be done to get this fixed.

P.S.: use the #bug:fault sub-category if you’re hitting a specific crash/error , or the #bug:fp sub-category for rules-related behaviour

Any Suggestions and workaround which we can implement ?

Hi Team
Any updates on this request ? Will some one be picking it up?

Hi,

Which tool are you using to execute your unit tests ?

Thanks.

Hi @mickaelcaro we are using the Azure devops task
mentioned below
steps:

  • task: SonarSource.sonarqube.15B84CA1-B62F-4A2A-A403-89B77A063157.SonarQubePrepare@4
    displayName: ‘Prepare analysis on SonarQube’
    inputs:

to perform the sonar analysis .

@mickaelcaro and we are using the below steps to perform the sonar analysis
steps:

  • task: SonarSource.sonarqube.6D01813A-9589-4B15-8491-8164AEB38055.SonarQubeAnalyze@4
    displayName: ‘Run Code Analysis’
    continueOnError: true
    condition: succeededOrFailed()

Ok for SonarQube analysis, but be careful, we are not in any way executing unit tests themselves, we are only relying on provided trx / coverage / coveragexml files to feed the analyzed and display number of unit tests and their coverage if applicable.

Please note also that current version of the dotnet test tool is not able to collect code coverage on linux machines (See https://github.com/Microsoft/vstest/issues/981)

Mickaël

we used this one "vstest running tests written using xUnit " Please suggest if this is right.

Yes this is right, but i’m very not sure about the coverage collection in linux environment. Do you have the possibility to test the whole build on a windows machine ?

Yes the whole build shows proper coverage on windows machine.
May i know the advantages in details if we think about moving to Sonar Cloud ?
If i can get a proper comparison then it will be easier for me to highlight it among the stakeholders.

Hi,

You can find some information on this topic : SonarCloud vs SonarQube

If you have more precise questions, i’ll invite you to reach our sales representatives directly.

Mickaël

Thanks for the reply @mickaelcaro

@mickaelcaro i have tested one build on a windows agent and this Project shows 0 code coverage there . “2019-11-07T05:47:55.1118579Z ##[debug]set SONARQUBE_SCANNER_PARAMS={“sonar.host.url”:”/",“sonar.login”:,“sonar.projectKey”:“SspPolicyTransactionService”,“sonar.projectName”:“SspPolicyTransactionService”,“sonar.projectVersion”:“1.0”,“sonar.scanner.metadataFilePath”:“d:\a\_temp\sonar\20191107.4\dc0df743-1e3a-232a-00fd-4c35a8b983e0\report-task.txt”,"/d:sonar.cs.vscoveragexml.reportsPaths":""\.coveragexml"","/d:sonar.cpd.exclusions":""**/*test.cs""}" Are we missing some parameters at our end which shows 0 coverage.

Hi,

Where is located your coveragexml path ? Given the sonar.cs.vscoveragexml.reportsPaths , it should be located under the root path (thus for better finding, please use an absolute path, with wildcards (See the doc : https://sonarcloud.io/documentation/analysis/coverage/)

it get’s published here /home/vsts/work/1/s/TestResults/Coverage/coverage.cobertura.xml
We are using Azure hosted agents here to run the Build . Please suggest if we check with some other options too.