SonarCloud : - 9.0
Scanner: 5.13 OR 5.0.3
CI/CD :- Jenkins
Language:- .NET
Build:- MSBuild.exe(version 14 for scanner and 4 for building
).
We are trying to achieve code coverage for our .NET projects. The project base directory contains multiple sln(solutions) under the root folder and also we have created separate unit test case solution under the same root folder.
While building the solutions on Jenkins pipeline call targets we are building all solutions in build pipeline but when we are seeing the code coverage it is only showing the first solution code coverage from that build pipeline
For ex:-
Build:-
Solution1:- ABC.sln
Solution2:- BCD.sln
Solution3:- CDC.sln
We are able to see the unit test case code coverage for ABC.sln on sonar dashboard but the rest of the solutions are not showing any code coverage.
Additionally from CDC.sln and BCD.sln we are seeing (n) lines to cover for newly added code on sonar dashboard.
In Sonar.Sources we can see the lots of files are including but in Sonar.Tests we are not seeing any unit test case files as we haven’t manually configured Sonar.Sources And Sonar.Tests in scanner starting part.
We are able to generate the open cover and unit test case result xml’s and will attach FYR.
We are seeing some issue with sonar end logs.
09:21:23.611 DEBUG: Skipping the file (ID ‘1998’, path ‘Utils\GlobalResources\Resource.Designer.cs’, NO INDEXED PATH), line ‘56’, visitCount ‘0’ because file is not indexed or does not have the supported language.
09:21:16.488 DEBUG: Analyzing coverage with wildcardPatternFileProvider with base dir ‘C:\Build\Products\Branch1.’ and file separator ''.
Did not find deterministic source path in ‘\UnitTests\Tests\Abc.cs’. Will skip this coverage entry. Verify sonar.sources in .sonarqube\out\sonar-project.properties.
Our unit test cases are passing while building the project.
09:21:16.491 DEBUG: Did not find deterministic source path in 'F:\Build\Products\MyBranch\Tests\UnitTests\UnitTests\Tests\GuidGeneratorUnitTests.cs'. Will skip this coverage entry. Verify sonar.sources in .sonarqube\out\sonar-project.properties.
09:21:16.491 DEBUG: CoveredFile created: (ID '1', path 'F:\Build\Products\MyBranch\Tests\UnitTests\UnitTests\Tests\GuidGeneratorUnitTests.cs', NO INDEXED PATH).
It seems that the paths in the coverage report don’t match the paths analysis is seeing.
I’m not sure what you expect from the files you sent. You need to look into why / how the paths the scanner is seeing in the coverage report don’t match the ones it’s seeing during analysis.
Regarding your ‘Scanner details.txt’ file, I don’t understand why run_opencover appears after sonarqube_end. If you want OpenCover results taken into account in the analysis, it’ll need to run before analysis ends.