which versions are you using (SonarQube, Scanner, Plugin, and any relevant extension)
what are you trying to achieve
what have you tried so far to achieve this
I am using SonarCloud in my Azure pipeline running in Linux and using dotnet build and test. It is working as expected up to reading the code coverage file. It errors with this message
“Could not import coverage report ‘/home/vsts/work/_temp/folder1/folder/coverage.cobertura.xml’ because 'Missing root element in /home/vsts/work/_temp/folder/folder/coverage.cobertura.xml at line 2”
I know the report is good because I publish it into the pipeline and it shows up on the summary page of the run. I have been fighting getting SonarCloud to find the code coverage files but now it would be nice to have SonarCloud read the darn thing…
I’m working with C# the analysis is working fine it’s just the code coverage that it cannot seem to find. I know the code coverage is being generated because it shows up on the code coverage tab in the summary
Currently the dotnet analyzer does not support the Cobertura format. We only support VS Coverage, DotCover and OpenCover. The parameters for coverage import can be found here: Test Coverage & Execution | SonarQube Docs
What tool do you use to generate coverage? Can you please check if it can export in OpenCover format? Most of them do.
Any suggestions for changes that will end up with SonarCloud having the code coverage and I still have the summary report will satisfy my expected results
Additional details don’t know if they are important:
There are 5 test projects testing the 4 projects, Client, Server, Business Layer, and Data Layer.
I have read through the link you sent and the info that they sent me to. I ended up just confused more then ever mostly because of the documenting every type of code and testing and reporting types…
I also hate that in azure I can’t see where the reports are being stored and their format. So that makes it difficult to determine what paths to point the report generator and SonarCloud to.
It would be great if the support was documented in something like this
Code Language
Test Method
Test Output type
Test Report type
once that is determined lay out the settings for SonarCloud, the Test Runner, The Report Generator etc.
so the user has one place that lays out all the settings for their instance to be successful getting their testing and coverage into the locations that SonarCloud can access and still support their CI systems reporting functions.
I had a little problem with the Test not finding the runsettings.xml files so I included them as resources in the build. That did the trick and now the opencover reports are importing correctly into SonarCloud!
Along the way I found that all the suggested /p commands did not work while running in the console which was disturbing since just about all the information I found suggested that they should. All the testing of the suggested fixes boiled down to adding the runsettings.xml and then placing them in the build directory which enabled the simple dotnet test --collect:“XPlat Code Coverage” --settings runsettings.xml command to get the output required.
Again I thank you, @costin.zaharia, for setting me on the path to finding a solution!
@Leonardo-Ferreira I don’t know how this will help you, I don’t use yml in building my pipeline in Azure, I use the visual interface. I exported my CI Build to yml so here you go: