Missing code coverage and lines of code in sonarqube using opencover for a c# project

2.2k views Asked by At

I am using the sonarqube with opencover to generate the coverage report for a c# project. The problem that I have is that the Code coverage is empty and Lines of code display 0: Sonarqube project details.

But when I use the reportgenerator to display the opencover result file, it shows Total lines of code and coverage: OpenCover report - using reportgenerator.

I am using this tools:

  • SonarQube 6.5
  • OpenCover.4.6.519
  • SonarQube.Scanner.MSBuild 3.0.2
  • MSbuild 15.3.4.9

I am running this commands::

 - MSBuild.SonarQube.Runner.exe begin /k:"SonarTestK" /n:"SonarTestN" /v:"1.0" /d:sonar.cs.opencover.reportsPaths="D:\Projects\SonarQubeTest\opencover.xml"

 - "D:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\15.0\Bin\msbuild"

 - "D:\Projects\SonarQubeTest\packages\OpenCover.4.6.519\tools\OpenCover.Console.exe" -output:"D:\Projects\SonarQubeTest\opencover.xml" -register:user -target:"D:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\IDE\CommonExtensions\Microsoft\TestWindow\vstest.console.exe" -targetargs:"UnitTestProject1\bin\Debug\UnitTestProject1.dll"

 - MSBuild.SonarQube.Runner.exe end

Console response for opencover:

Starting test execution, please wait...
Passed   TestMethod1

Total tests: 1. Passed: 1. Failed: 0. Skipped: 0.
Test Run Successful.
Test execution time: 1.1620 Seconds
Committing...
Visited Classes 1 of 1 (100)
Visited Methods 1 of 1 (100)
Visited Points 2 of 2 (100)
Visited Branches 1 of 1 (100)

==== Alternative Results (includes all methods including those without correspon
ding source) ====
Alternative Visited Classes 1 of 1 (100)
Alternative Visited Methods 2 of 2 (100)

Response for MSBuild.SonarQube.Runner.exe end:

Default properties file was found at D:\Kits\Development\sonarqube-6.5\bin\Sonar
Qube.Analysis.xml
Loading analysis properties from D:\Kits\Development\sonarqube-6.5\bin\SonarQube
.Analysis.xml
Post-processing started.
SONAR_SCANNER_OPTS is not configured. Setting it to the default value of -Xmx102
4m
Calling the SonarQube Scanner...
INFO: Scanner configuration file: D:\Kits\Development\sonarqube-6.5\bin\sonar-sc
anner-3.0.3.778\bin\..\conf\sonar-scanner.properties
INFO: Project root configuration file: d:\Projects\SonarQubeTest\.sonarqube\out\
sonar-project.properties
INFO: SonarQube Scanner 3.0.3.778
INFO: Java 1.8.0_121 Oracle Corporation (64-bit)
INFO: Windows 8.1 6.3 amd64
INFO: SONAR_SCANNER_OPTS=-Xmx1024m
INFO: User cache: C:\Users\andrei.barsa\.sonar\cache
INFO: Load global settings
INFO: Load global settings (done) | time=109ms
INFO: User cache: C:\Users\andrei.barsa\.sonar\cache
INFO: Load plugins index
INFO: Load plugins index (done) | time=49ms
INFO: SonarQube server 6.5.0
INFO: Default locale: "en_GB", source code encoding: "windows-1252" (analysis is
 platform dependent)
INFO: Process project properties
INFO: Load project repositories
INFO: Load project repositories (done) | time=156ms
INFO: Load quality profiles
INFO: Load quality profiles (done) | time=24ms
INFO: Load active rules
INFO: Load active rules (done) | time=415ms
INFO: Load metrics repository
INFO: Load metrics repository (done) | time=80ms
INFO: Publish mode
WARNING: WARN: SCM provider autodetection failed. No SCM provider claims to supp
ort this project. Please use sonar.scm.provider to define SCM of your project.
INFO: Project key: SonarTestK
INFO: -------------  Scan UnitTestProject1
INFO: Load server rules
INFO: Load server rules (done) | time=109ms
INFO: Base dir: D:\Projects\SonarQubeTest\UnitTestProject1
INFO: Working dir: d:\Projects\SonarQubeTest\.sonarqube\out\.sonar\mod1
INFO: Test paths: UnitTest1.cs, Properties/AssemblyInfo.cs, packages.config
INFO: Source encoding: UTF-8, default locale: en_GB
INFO: Index files
INFO: 3 files indexed
INFO: Quality profile for cs: Sonar way
WARNING: WARN: SCM provider autodetection failed. No SCM provider claims to supp
ort this project. Please use sonar.scm.provider to define SCM of your project.
INFO: Project key: SonarTestK
INFO: -------------  Scan UnitTestProject1
INFO: Load server rules
INFO: Load server rules (done) | time=109ms
INFO: Base dir: D:\Projects\SonarQubeTest\UnitTestProject1
INFO: Working dir: d:\Projects\SonarQubeTest\.sonarqube\out\.sonar\mod1
INFO: Test paths: UnitTest1.cs, Properties/AssemblyInfo.cs, packages.config
INFO: Source encoding: UTF-8, default locale: en_GB
INFO: Index files
INFO: 3 files indexed
INFO: Quality profile for cs: Sonar way
INFO: Sensor C# [csharp]
INFO: Sensor C# [csharp] (done) | time=22ms
INFO: Sensor C# Unit Tests Coverage Report Import [csharp]
INFO: Parsing the OpenCover report D:\Projects\SonarQubeTest\opencover.xml
INFO: Adding this code coverage report to the cache for later reuse: D:\Projects
\SonarQubeTest\opencover.xml
INFO: Sensor C# Unit Tests Coverage Report Import [csharp] (done) | time=370ms
INFO: Sensor C# Integration Tests Coverage Report Import [csharp]
INFO: Sensor C# Integration Tests Coverage Report Import [csharp] (done) | time=
1ms
INFO: Sensor C# Unit Test Results Import [csharp]
INFO: Sensor C# Unit Test Results Import [csharp] (done) | time=0ms
INFO: Sensor SonarJavaXmlFileSensor [java]
INFO: Sensor SonarJavaXmlFileSensor [java] (done) | time=0ms
INFO: Sensor Analyzer for "php.ini" files [php]
INFO: Sensor Analyzer for "php.ini" files [php] (done) | time=16ms
INFO: No SCM system was detected. You can use the 'sonar.scm.provider' property
to explicitly specify it.
INFO: -------------  Scan SonarQubeTest
INFO: Base dir: D:\Projects\SonarQubeTest\SonarQubeTest
INFO: Working dir: d:\Projects\SonarQubeTest\.sonarqube\out\.sonar\mod0
INFO: Test paths: Class1.cs, Class2.cs, Class3.cs, Class4.cs, Program.cs, Proper
ties/AssemblyInfo.cs, App.config, packages.config
INFO: Source encoding: UTF-8, default locale: en_GB
INFO: Index files
INFO: 8 files indexed
INFO: Quality profile for cs: Sonar way
INFO: Sensor C# [csharp]
INFO: Sensor C# [csharp] (done) | time=0ms
INFO: Sensor C# Unit Tests Coverage Report Import [csharp]
INFO: Parsing the OpenCover report D:\Projects\SonarQubeTest\opencover.xml
INFO: Adding this code coverage report to the cache for later reuse: D:\Projects
\SonarQubeTest\opencover.xml
INFO: Sensor C# Unit Tests Coverage Report Import [csharp] (done) | time=6ms
INFO: Sensor C# Integration Tests Coverage Report Import [csharp]
INFO: Sensor C# Integration Tests Coverage Report Import [csharp] (done) | time=
0ms
INFO: Sensor C# Unit Test Results Import [csharp]
INFO: Sensor C# Unit Test Results Import [csharp] (done) | time=0ms
INFO: Sensor SonarJavaXmlFileSensor [java]
INFO: Sensor SonarJavaXmlFileSensor [java] (done) | time=0ms
INFO: Sensor Analyzer for "php.ini" files [php]
INFO: Sensor Analyzer for "php.ini" files [php] (done) | time=1ms
INFO: No SCM system was detected. You can use the 'sonar.scm.provider' property
to explicitly specify it.
INFO: -------------  Scan SonarTestN
INFO: Base dir: D:\Projects\SonarQubeTest
INFO: Working dir: d:\Projects\SonarQubeTest\.sonarqube\out\.sonar
INFO: Source paths: packages/MSTest.TestAdapter.1.1.18/build/_common/Microsoft.V
isualStudio.TestPlatform.MSTest.TestAdapter.dll, packages/MSTest.TestAdapter.1.1
.18/build/_common/Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServ
ices.Interface.dll, packages/MSTest.TestAdapter.1.1.18/build/_common/Microsoft.V
isualStudio.TestPlatform.MSTestAdapter.PlatformServices.dll
INFO: Source encoding: windows-1252, default locale: en_GB
INFO: Index files
INFO: 3 files indexed
INFO: Sensor SonarJavaXmlFileSensor [java]
INFO: Sensor SonarJavaXmlFileSensor [java] (done) | time=0ms
INFO: Sensor Analyzer for "php.ini" files [php]
INFO: Sensor Analyzer for "php.ini" files [php] (done) | time=0ms
INFO: Sensor Zero Coverage Sensor
INFO: Sensor Zero Coverage Sensor (done) | time=35ms
INFO: Sensor CPD Block Indexer
INFO: Sensor CPD Block Indexer (done) | time=0ms
INFO: No SCM system was detected. You can use the 'sonar.scm.provider' property
to explicitly specify it.
INFO: Calculating CPD for 0 files
INFO: CPD calculation finished
INFO: Analysis report generated in 790ms, dir size=26 KB
INFO: Analysis reports compressed in 47ms, zip size=11 KB
INFO: Analysis report uploaded in 313ms
INFO: ANALYSIS SUCCESSFUL, you can browse http://localhost:9000/dashboard/index/
SonarTestK
INFO: Note that you will be able to access the updated dashboard once the server
 has processed the submitted analysis report
INFO: More about the report processing at http://localhost:9000/api/ce/task?id=A
V5a7bg5XJTvR5tNQu26
INFO: Task total time: 6.812 s
INFO: ------------------------------------------------------------------------
INFO: EXECUTION SUCCESS
INFO: ------------------------------------------------------------------------
INFO: Total time: 10.052s
INFO: Final Memory: 46M/315M
INFO: ------------------------------------------------------------------------
The SonarQube Scanner has finished
09:01:22.99  Creating a summary markdown file...
09:01:22.995  Analysis results: http://localhost:9000/dashboard/index/SonarTestK

09:01:22.996  Post-processing succeeded.

Response from Sonarqube background task:

SonarQube plugins:
  - C# 5.10.1.1411 (csharp)
  - SonarPython 1.8.0.1496 (python)
  - SonarJava 4.12.0.11033 (java)
  - Flex 2.3 (flex)
  - Git 1.2 (scmgit)
  - SonarXML 1.4.3.1027 (xml)
  - SonarPHP 2.10.0.2087 (php)
  - SVN 1.5.0.715 (scmsvn)
  - SonarJS 3.1.1.5128 (javascript)
Global properties:
  - sonar.core.id=AV4y6t-o3KatRxeBXW5f
  - sonar.core.startTime=2017-09-07T08:22:08+0300
Settings for module: SonarTestK:SonarTestK:EC544BE4-F53E-42C8-826A-F179665AF4A4
  - sonar.moduleKey=SonarTestK:SonarTestK:EC544BE4-F53E-42C8-826A-F179665AF4A4
  - sonar.projectBaseDir=d:\Projects\SonarQubeTest\UnitTestProject1
  - sonar.projectKey=SonarTestK:SonarTestK:EC544BE4-F53E-42C8-826A-F179665AF4A4
  - sonar.projectName=UnitTestProject1
  - sonar.sourceEncoding=utf-8
  - sonar.sources=
  - sonar.stylecop.projectFilePath=d:\Projects\SonarQubeTest\UnitTestProject1\UnitTestProject1.csproj
  - sonar.tests=d:\Projects\SonarQubeTest\UnitTestProject1\UnitTest1.cs,d:\Projects\SonarQubeTest\UnitTestProject1\Properties\AssemblyInfo.cs,d:\Projects\SonarQubeTest\UnitTestProject1\packages.config
  - sonar.working.directory=d:\Projects\SonarQubeTest\.sonarqube\out\.sonar\mod1
Settings for module: SonarTestK:SonarTestK:84E50744-CAC7-4CAF-9996-C5D06A9C21B7
  - sonar.moduleKey=SonarTestK:SonarTestK:84E50744-CAC7-4CAF-9996-C5D06A9C21B7
  - sonar.projectBaseDir=d:\Projects\SonarQubeTest\SonarQubeTest
  - sonar.projectKey=SonarTestK:SonarTestK:84E50744-CAC7-4CAF-9996-C5D06A9C21B7
  - sonar.projectName=SonarQubeTest
  - sonar.sourceEncoding=utf-8
  - sonar.sources=
  - sonar.stylecop.projectFilePath=d:\Projects\SonarQubeTest\SonarQubeTest\SonarQubeTest.csproj
  - sonar.tests=d:\Projects\SonarQubeTest\SonarQubeTest\Class1.cs,d:\Projects\SonarQubeTest\SonarQubeTest\Class2.cs,d:\Projects\SonarQubeTest\SonarQubeTest\Class3.cs,d:\Projects\SonarQubeTest\SonarQubeTest\Class4.cs,d:\Projects\SonarQubeTest\SonarQubeTest\Program.cs,d:\Projects\SonarQubeTest\SonarQubeTest\Properties\AssemblyInfo.cs,d:\Projects\SonarQubeTest\SonarQubeTest\App.config,d:\Projects\SonarQubeTest\SonarQubeTest\packages.config
  - sonar.working.directory=d:\Projects\SonarQubeTest\.sonarqube\out\.sonar\mod0
Settings for module: SonarTestK
  - sonar.cs.opencover.reportsPaths=D:\Projects\SonarQubeTest\opencover.xml
  - sonar.modules=84E50744-CAC7-4CAF-9996-C5D06A9C21B7,EC544BE4-F53E-42C8-826A-F179665AF4A4
  - sonar.projectBaseDir=d:\Projects\SonarQubeTest
  - sonar.projectKey=SonarTestK
  - sonar.projectName=SonarTestN
  - sonar.projectVersion=1.0
  - sonar.scanAllFiles=true
  - sonar.sourceEncoding=windows-1252
  - sonar.sources=d:\Projects\SonarQubeTest\packages\MSTest.TestAdapter.1.1.18\build\_common\Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.dll,d:\Projects\SonarQubeTest\packages\MSTest.TestAdapter.1.1.18\build\_common\Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices.Interface.dll,d:\Projects\SonarQubeTest\packages\MSTest.TestAdapter.1.1.18\build\_common\Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices.dll
  - sonar.visualstudio.enable=false
  - sonar.working.directory=d:\Projects\SonarQubeTest\.sonarqube\out\.sonar

Thank you, Andrei

0

There are 0 answers