Code Coverage shows 0 even though dotCover reports are being provided

Hi ,
I want to use dotCover’s generated report to be imported by SonarQube for Code Coverage using TFS CI Pipeline.
I provided the parameter so that it will pick the report from the path and analyze it further to reflect in the Sonar Dashboard
I have included parameters in the Begin step like this -
begin /k:"$(ProjectName)" /d:sonar.host.url="http://<ip>:9000/" /d:sonar.login="$(ProjectKey)" /d:sonar.verbose=true /d:sonar.cs.dotcover.reportsPaths="//abc/CodeCover/CodeCover.html"

When I run the Sonar-Runner it appears that it is parsing the dotcover reports and also says that Execution success but still the code coverage is showing 0% in the Sonar Dashboard .

Need help regarding how can I achieve code coverage after passing dotCover reports using TFS Pipeline ?

Sharing Logs for reference:

2021-04-28T05:12:12.3492783Z 10:42:12.349 INFO: Parsing the dotCover report D:\Shared\DotCover\Exported\Mar21PICodeCover\src\991.html
2021-04-28T05:12:12.3532674Z 10:42:12.353 INFO: Parsing the dotCover report D:\Shared\DotCover\Exported\Mar21PICodeCover\src\992.html
2021-04-28T05:12:12.3582548Z 10:42:12.358 INFO: Parsing the dotCover report D:\Shared\DotCover\Exported\Mar21PICodeCover\src\993.html
2021-04-28T05:12:12.3632411Z 10:42:12.363 INFO: Parsing the dotCover report D:\Shared\DotCover\Exported\Mar21PICodeCover\src\994.html
2021-04-28T05:12:12.3692253Z 10:42:12.369 INFO: Parsing the dotCover report D:\Shared\DotCover\Exported\Mar21PICodeCover\src\995.html
2021-04-28T05:12:12.3742132Z 10:42:12.374 INFO: Parsing the dotCover report D:\Shared\DotCover\Exported\Mar21PICodeCover\src\996.html
2021-04-28T05:12:12.3791987Z 10:42:12.379 INFO: Parsing the dotCover report D:\Shared\DotCover\Exported\Mar21PICodeCover\src\997.html
2021-04-28T05:12:12.3831884Z 10:42:12.383 INFO: Parsing the dotCover report D:\Shared\DotCover\Exported\Mar21PICodeCover\src\998.html
2021-04-28T05:12:12.3881755Z 10:42:12.387 INFO: Parsing the dotCover report D:\Shared\DotCover\Exported\Mar21PICodeCover\src\999.html
2021-04-28T05:12:12.3931623Z 10:42:12.392 INFO: Adding this code coverage report to the cache for later reuse: D:\Shared\DotCover\Exported\Mar21PICodeCover.html
2021-04-28T05:12:12.3931623Z 10:42:12.393 INFO: Sensor C# Tests Coverage Report Import [csharp] (done) | time=24711ms
2021-04-28T05:12:12.3931623Z 10:42:12.393 INFO: ------------- Run sensors on project
2021-04-28T05:12:12.3971513Z 10:42:12.397 DEBUG: 'Java CPD Block Indexer' skipped because there is no related file in current project
2021-04-28T05:12:12.3971513Z 10:42:12.397 DEBUG: Sensors : Zero Coverage Sensor
2021-04-28T05:12:12.3971513Z 10:42:12.397 INFO: Sensor Zero Coverage Sensor
2021-04-28T05:12:16.9405547Z 10:42:16.940 INFO: Sensor Zero Coverage Sensor (done) | time=4543ms

2021-04-28T05:12:16.9415523Z 10:42:16.941 INFO: SCM Publisher No SCM system was detected. You can use the 'sonar.scm.provider' property to explicitly specify it.
2021-04-28T05:12:18.6899258Z 10:42:18.689 INFO: CPD Executor 354 files had no CPD blocks
2021-04-28T05:12:18.6909212Z 10:42:18.689 INFO: CPD Executor Calculating CPD for 4306 files
2021-04-28T05:12:18.6909212Z 10:42:18.690 DEBUG: Detection of duplications for

I got the solution , when using TFS Build just ensure that that the sonar build and dotCover report being generated are from the same machine . The file path should be completely in sync .

While implementing the whole process in any CI/CD Pipeline the most common failure reason can be related to this situation only - where we run sonar scanner on one machine and so code coverage using dotCover / (code coverage tool) in another machine. Neither it should be case where 2 almost similar branch are used to serve this purpose .

Its better to automate the whole process something like this -
Start SonarQube → Build Solution (main solution) → Generate dotCover → Sonar Build → End Solution

Hope this helps .

2 Likes

Thanks for the follow-up!

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.