1
votes

I am trying to set up unit testing and code coverage for a C# project. I am using sonar runner as the analyzer, Gallio 3.4.14 OpenCover4.5.1 This is the sonar-project.properties file:

sonar.projectKey=Foo

sonar.projectName=Foo-SonarQube Runner

sonar.projectVersion=1.0

# Path to the source directories (required)
sonar.sources=.

sonar.language=cs

sonar.sourceEncoding=UTF-8

sonar.dotnet.visualstudio.solution.file=Foo.sln

sonar.silverlight.4.mscorlib.location=C:\Program Files (x86)\Reference Assemblies
\Microsoft\Framework\Silverlight\v5.0

sonar.dotnet.excludeGeneratedCode=true

sonar.dotnet.4.0.sdk.directory=C:/WIndows/Microsoft.NET/Framework/v4.0.30319
sonar.dotnet.version=4.0


sonar.gallio.runner=IsolatedProcess

sonar.gallio.coverage.tool=OpenCover 

sonar.donet.visualstudio.testProjectPattern=**.Tests;   **.UnitTests

sonar.opencover.installDirectory=C:/Program Files (x86)/OpenCover
sonar.dotnet.test.assemblies=FooUnitTests\bin\Release\FooUnitTests.dll 

It runs successfully but in the logs I see that Gallio didnt execute:

No assembly to check with Gendarme

Skipping the non generated assembly of project : Foo

No assembly to check with NDeps

Gallio won't execute as there are no test projects.

Any help will be appreciated

1

1 Answers

1
votes

Double-check your test project patterns: sonar.donet.visualstudio.testProjectPattern=**.Tests; **.UnitTests

Try this instead: sonar.donet.visualstudio.testProjectPattern=*Tests;*UnitTests

Also, toward the top of the sonar-runner output (within the first 20 or so lines), you should see some lines like this:

05:40:07.021 INFO  - Initializing Hibernate
05:40:13.601 INFO  - Load project settings
05:40:13.653 INFO  - The following 'sln' file has been found and will be used: C:\TeamCity\buildAgent\work\920b95942ca1a758\Sonar\MyProject-Sonar.sln
05:40:17.276 INFO  - The project 'MyProject.Tests' has been qualified as a test project.
05:40:19.235 INFO  - The project 'MyOther.Project.Tests' has been qualified as a test project.

If you're not seeing this, try running sonar-runner with -X to enable debugging output. This should give you more details as to what patterns are being used to match test projects.

Additionally, any paths need to use forward slashes (/), so the following need to be changed:

sonar.silverlight.4.mscorlib.location=C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\Silverlight\v5.0
sonar.dotnet.test.assemblies=FooUnitTests\bin\Release\FooUnitTests.dll 

To this:

sonar.silverlight.4.mscorlib.location=C:/Program Files (x86)/Reference Assemblies/Microsoft/Framework/Silverlight/v5.0
sonar.dotnet.test.assemblies=FooUnitTests/bin/Release/FooUnitTests.dll