Attachments:
D:\Platform Development Team\Main\Source\ExportSystemV7\SystemEngine.UnitTest\TestResults\caeecd89-ca1d-4404-839c-3aaaaba5f396\efalchero_WSAMZN-5MANHRAT_2024-03-08.20_03_10.coverage`
The configuration of sonar scanner is simple:
dotnet sonarscanner begin /o:"..." /k:"..." /d:sonar.host.url="https://sonarcloud.io" /d:sonar.token="..." dotnet build SystemEngine/SystemEngine.csproj /t:Rebuild dotnet test SystemEngine.UnitTest/SystemEngine.UnitTest.csproj --collect "Code Coverage" dotnet sonarscanner end /d:sonar.token="..."
but from the log I get these rows:
INFO: Sensor JaCoCo XML Report Importer [jacoco] INFO: 'sonar.coverage.jacoco.xmlReportPaths' is not defined. Using default locations: target/site/jacoco/jacoco.xml,target/site/jacoco-it/jacoco.xml,build/reports/jacoco/test/jacocoTestReport.xml INFO: No report imported, no coverage information will be imported by JaCoCo XML Report Importer INFO: Sensor JaCoCo XML Report Importer [jacoco] (done) | time=2ms
Project in sonarcloud cannot get coverage and unit tests, please tell me how to troubleshoot. Is there any problem with any configuration?
dotnet sonarscanner begin /o:"vidrio" /k:"..." /d:sonar.host.url="https://sonarcloud.io" /d:sonar.token="..." /d:sonar.cs.vscoveragexml.reportsPaths=coverage.xml
dotnet build SystemEngine/SystemEngine.csproj /t:Rebuild
dotnet-coverage collect "dotnet test SystemEngine.UnitTest/SystemEngine.UnitTest.csproj" -f xml -o "coverage.xml"
dotnet sonarscanner end /d:sonar.token="..."
Now I have a strange result in SonarCloud with this configuration. SonarScanner uploads on SonarCloud both projects, including also the UnitTest, and puts them in two separate subfolders in my SonarCloud project.
I found a workaround changing a little bit the SonarScanner configuration moving the collect coverage before the SonarScanner begin step:
dotnet-coverage collect "dotnet test SystemEngine.UnitTest/SystemEngine.UnitTest.csproj" -f xml -o "coverage.xml"
dotnet sonarscanner begin /o:"vidrio" /k:"..." /d:sonar.host.url="https://sonarcloud.io" /d:sonar.token="..." /d:sonar.cs.vscoveragexml.reportsPaths=coverage.xml
dotnet build SystemEngine/SystemEngine.csproj /t:Rebuild
dotnet sonarscanner end /d:sonar.token="..."
Is it correct what I’m doing or do I still miss something? I don’t want the UniTest uploaded in my SonarCloud project.
This sounds expected, not strange. As long as you don’t see Lines of Code being calculated for your test projects, they aren’t being counted against your license.