Search code examples
c#sonarqubegallioopencover

Sonarqube with gallio openCover - how to?


I am trying to get the C# unit test coverage.
Below is my sonar setup, but when I run sonar runner I don't see any thing related to unite test coverage and the result on browser it does not show any unit test coverage.
My question is: the sonar c# plugin page says that gallio is installed as part of it. I am assuming that I need not have to install gallio externally but when I run sonar runner, it invokes gallio which in turn invokes opencover to get the coverage ?
What am i doing wrong ?

# Required metadata

sonar.projectKey=MyProg    
sonar.projectName=MyProg

sonar.projectVersion=1.0

# sonar.sources=C:/MyProj
sonar.sources=.
sonar.language=cs

# Encoding of the source code

sonar.sourceEncoding=UTF-8



# Additional parameters

# sonar.my.property=value





#Core C# Settings
sonar.dotnet.visualstudio.solution.file=AS.sln
sonar.dotnet.excludeGeneratedCode=true
sonar.dotnet.4.0.sdk.directory=C:/Windows/Microsoft.NET/Framework/v4.0.30319
sonar.dotnet.version=4.0 



#Gendarme
sonar.gendarme.mode=

# Gallio / Unit Tests
sonar.gallio.mode=
sonar.gallio.coverage.tool=OpenCover
sonar.gallio.runner=IsolatedProcess
sonar.dotnet.visualstudio.testProjectPattern=*Test*
sonar.opencover.installDirectory=C:/opencover.4.5.2506/

# FXCop 
sonar.fxcop.mode=skip

# StyleCop 
sonar.stylecop.mode=skip

# NDeps
sonar.ndeps.mode=skip

I am not finding any information about gallio in sonar log:

   c:\Program Files\sonar-runner-dist-2.4\sonar-runner-2.4\bin\..
SonarQube Runner 2.4
Java 1.7.0_40 Oracle Corporation (64-bit)
Windows 7 6.1 amd64
INFO: Error stacktraces are turned on.
INFO: Runner configuration file: c:\Program Files\sonar-runner-dist-2.4\sonar-runner-2.4\bin\..\conf\sonar-runner.properties
INFO: Project configuration file: C:\cna2\Columbus-NA\ERP\SourceCode\Projects\AS\sonar-project.properties
INFO: Default locale: "en_US", source code encoding: "UTF-8"
INFO: Work directory: C:\cna2\Columbus-NA\ERP\SourceCode\Projects\AS\.\.sonar
INFO: SonarQube Server 4.5
18:30:31.202 INFO  - Load global referentials...
18:30:31.309 INFO  - Load global referentials done: 109 ms
18:30:31.316 INFO  - User cache: C:\Users\vikas.c\.sonar\cache
18:30:31.323 INFO  - Install plugins
18:30:31.433 INFO  - Install JDBC driver
18:30:31.438 INFO  - Create JDBC datasource for jdbc:mysql://localhost:3306/sonar?useUnicode=true&characterEncoding=utf8
18:30:32.494 INFO  - Initializing Hibernate
18:30:33.577 INFO  - Load project referentials...
18:30:33.829 INFO  - Load project referentials done: 253 ms
18:30:33.829 INFO  - Load project settings
18:30:34.207 INFO  - Loading technical debt model...
18:30:34.234 INFO  - Loading technical debt model done: 27 ms
18:30:34.236 INFO  - Apply project exclusions
18:30:34.438 INFO  - -------------  Scan Sage AS
18:30:34.442 INFO  - Load module settings
18:30:34.603 INFO  - Language is forced to cs
18:30:34.603 INFO  - Loading rules...
18:30:35.074 INFO  - Loading rules done: 471 ms
18:30:35.091 INFO  - Configure Maven plugins
18:30:35.147 INFO  - Compare to previous analysis (2014-10-06)
18:30:35.153 INFO  - Compare over 30 days (2014-09-06, analysis of 2014-10-06 13:42:43.0)
18:30:35.154 INFO  - No quality gate is configured.
18:30:35.267 INFO  - Base dir: C:\cna2\Columbus-NA\ERP\SourceCode\Projects\AS\.
18:30:35.267 INFO  - Working dir: C:\cna2\Columbus-NA\ERP\SourceCode\Projects\AS\.\.sonar
18:30:35.268 INFO  - Source paths: .
18:30:35.268 INFO  - Source encoding: UTF-8, default locale: en_US
18:30:35.268 INFO  - Index files
18:30:35.599 INFO  - 132 files indexed
18:30:46.573 INFO  - Quality profile for cs: Sonar way
18:30:46.696 INFO  - All FxCop rules are disabled, skipping its execution.
18:30:46.699 INFO  - Sensor QProfileSensor...
18:30:46.704 INFO  - Sensor QProfileSensor done: 5 ms
18:30:46.704 INFO  - Sensor InitialOpenIssuesSensor...
18:30:46.729 INFO  - Sensor InitialOpenIssuesSensor done: 25 ms
18:30:46.729 INFO  - Sensor ProjectLinksSensor...
18:30:46.733 INFO  - Sensor ProjectLinksSensor done: 4 ms
18:30:46.734 INFO  - Sensor VersionEventsSensor...
18:30:46.856 INFO  - Sensor VersionEventsSensor done: 122 ms
18:30:46.856 INFO  - Sensor FileHashSensor...
18:30:46.878 INFO  - Sensor FileHashSensor done: 22 ms
18:30:46.878 INFO  - Sensor org.sonar.plugins.csharp.squid.CSharpSquidSensor@643926a2...
18:30:46.925 INFO  - 132 source files to be analyzed
18:30:47.818 INFO  - 132/132 source files analyzed
18:30:48.015 INFO  - Sensor org.sonar.plugins.csharp.squid.CSharpSquidSensor@643926a2 done: 1137 ms
18:30:48.015 INFO  - Sensor CPD Sensor (wrapped)...
18:30:48.015 INFO  - DefaultCpdEngine is used for cs
18:30:48.021 INFO  - Cross-project analysis disabled
18:30:48.601 INFO  - Sensor CPD Sensor (wrapped) done: 586 ms
18:30:48.830 INFO  - Execute decorators...
18:30:50.537 INFO  - Store results in database
18:30:53.723 INFO  - ANALYSIS SUCCESSFUL, you can browse http://localhost:9000/dashboard/index/SageCNAAS
18:30:53.779 INFO  - Executing post-job class org.sonar.plugins.core.issue.notification.SendIssueNotificationsPostJob
18:30:53.781 INFO  - Executing post-job class org.sonar.plugins.core.batch.IndexProjectPostJob
18:30:53.823 INFO  - Executing post-job class org.sonar.plugins.dbcleaner.ProjectPurgePostJob
18:30:53.838 INFO  - -> Keep one snapshot per day between 2014-09-08 and 2014-10-05
18:30:53.839 INFO  - -> Keep one snapshot per week between 2013-10-07 and 2014-09-08
18:30:53.840 INFO  - -> Keep one snapshot per month between 2009-10-12 and 2013-10-07
18:30:53.841 INFO  - -> Delete data prior to: 2009-10-12
18:30:53.849 INFO  - -> Clean Sage AS [id=1]
18:30:53.854 INFO  - <- Clean snapshot 1850
INFO: ------------------------------------------------------------------------
INFO: EXECUTION SUCCESS
INFO: ------------------------------------------------------------------------
Total time: 23.752s
Final Memory: 16M/675M
INFO: ------------------------------------------------------------------------

Solution

  • First of all you have to define the test project pattern. sonar/opencover is not able to identify your test binaries. Secondly, if you are using sonar 4.3+ than you may want to know that sonar has ended its support for gallio and opencover. In this case you need to import coverage xml from outside to get you coverage. Please enhance your post with suitable information about version of sonar etc.