Hi,
we updated our DevOPs pipeline but still it not updating Code Coverage in sonar cloud. it always shows 0.0%. Need help
Hi,
we updated our DevOPs pipeline but still it not updating Code Coverage in sonar cloud. it always shows 0.0%. Need help
Hi @nitesh.barot and welcome to the community.
Can you please provide a bit more context ?
-Which kind of code do you analyse ? Was it working on the same project and branch before ?
Thanks.
Hi @mickaelcaro,
Thanks for the response.
We are analyzing Asp .Net 4.7 application. Sonar cloud analyzing is working fine but Code coverage is always 0.0%. And we are using Azure Dev Ops pipelines for build and deploy.
Can you please provider me more details or examples for Coverage file use?
Which tool are you using to execute your tests inside your pipeline ?
we are using XUnit framework for unit test.
Can you please apply this guide and see if it helps ?
Thanks !
This are the steps i have done:
SonarCloudAnalyze
And mentioned below settings:
extraProperties: |
sonar.exclusions=**/obj/**,**/*.dll
sonar.cs.xunit.reportsPaths=${Agent.TempDirectory}/**/XUnit.TestResults.xml
sonar.cs.vstest.reportsPaths=$(Agent.TempDirectory)/*.trx
sonar.cs.opencover.reportsPaths=$(Build.SourcesDirectory)/**/coverage.opencover.xml
Then - task: VSBuild@1
it has below argument added
arguments: ‘–configuration Release /p:CollectCoverage=true /p:CoverletOutputFormat=opencover --logger trx’
Hi,
Don’t mix multiple sources of test coverage files (like you did in extraProperties), choose only one, otherwise it may lead to weird behaviors.
Mickaël
After removing extra entries I am getting below errors:
##[error]12:57:16.400 ERROR: Error during SonarScanner execution
##[error]Error during parsing of generic test execution report. Look at the SonarQube documentation to know the expected XML format.
##[error]Caused by: java.io.FileNotFoundException:test-report.xml (The system cannot find the file specified)
Where is set this test-report path ?
This is how it is given:
sonar.testExecutionReportPaths=test-report.xml
This is how i am setting properties now:
extraProperties: |
sonar.sourceEncoding=UTF-8
sonar.projectBaseDir=$(System.DefaultWorkingDirectory)/Project Name
sonar.tests=src
sonar.test.inclusions=**/*.spec.ts
sonar.testExecutionReportPaths=test-report.xml
sonar.javascript.lcov.reportPaths=coverage/lcov.info
sonar.exclusions=**/*mock*.ts
Hi,
Just to summarize :
sonar.testExecutionReportPaths is a property to be set when you when to import generic test result files
If you are using VSTest inside your build pipeline, detection and setup of relevant properties should be made in an automatic manner
If you are using any other Test executable tool, you should add the relevant properties, according to the guide i gave the link above or this documentation
Hope that clarifies.
Mickaël
Hi,
Just to confirm does VSTS supports .Net Framework 4.7 ? Because we are getting below errors:
##[debug]Exited vstest.console.exe with code 0.
##[debug]PERF: ExecuteVsTestPhase.InvokeVSTest: took 15215.5814 ms
Vstest.console.exe exited with code 0
No Result Found to Publish
Hi,
Yes this is supported. This log is not related to SonarCloud though.
Those logs are related to VSTS task in pipeline.
But after that task in SonarCloudAnalyze below messages we are getting below messages:
sonar.cs.vstest.reportsPaths=D:\a\_temp/testresults/*.trx
Process returned exit code 0
Coverage report conversion completed successfully.
Process returned exit code 0
This property is intended to hold test result files, which should normally fill your number of test on SonarCloud. I would suggest to not set anything in your case since the Scanner will take care of finding those TRX by itself, them convert the binary file that is linked inside.
Let me know.
Thanks.
Ok i removed that setting but still it is not working.
Error message:
No test is available in D:\a\1\s\Application\TestProj.UnitTest\obj\Release\UnitTest.dll. Make sure that test discoverer & executors are registered and platform & framework version settings are appropriate and try again.
As per some articles do we need to install “Package NUnitTestAdapter” to resolve this ?