0

I’m integrating SonarQube in our build system – I installed sonar-runner-2.4 on our build agents and added the sonar-runner.properties for each solution (to the solution’s folder on TFS). When running the build I’m executing the sonar-runner after the solution has been compiled on the build agent. Everything seem to work except for the unit test:

On the build’s log I see that almost 200 tests ran and were completed successfully and in the sonar-runner log I see the following:

14:23:29.808 INFO  - 583/583 source files analyzed  
14:23:30.809 INFO  - Sensor org.sonar.plugins.csharp.squid.CSharpSquidSensor@1a50b87 done: 14937 ms  
14:23:30.809 INFO  - Sensor org.sonar.plugins.csharp.core.CSharpUnitTestResultsProvider$CSharpUnitTestResultsImportSensor@97edbc...  
14:23:30.821 INFO  - Sensor org.sonar.plugins.csharp.core.CSharpUnitTestResultsProvider$CSharpUnitTestResultsImportSensor@97edbc done: 12 ms

Which seems ok I guess, but when logging into the sonar server it shows that 0 tests ran.

On the sonar-runner.properties file I set the following value to

sonar.cs.vstest.reportsPaths:
sonar.cs.vstest.reportsPaths=TestResults/*.trx

when in this case there are 3 vstest trx files located in the following local path on the build agent: `

D:\sTFS\22965\Sources\TestResults

` (see TestResults.jpg attached). Attached is the sonar-runner.properties file. I also attached a screen capture from the sonarqube server (see SonarServer.jpg attached).

Can you please advise what might be the problem? TestResults

SonarServer

sonar-runner.properties

AranZaiger
  • 61
  • 1
  • 10
Guy Salton
  • 617
  • 1
  • 5
  • 6

1 Answers1

0

You should be seeing some messages like:

INFO - Parsing the Visual Studio Test Results file ...

for each unit test result file that is being parsed, see VisualStudioTestResultsFileParser.java#L34

Can you try to pass an absolute path pattern to sonar.cs.vstest.reportsPaths? My guess is that the issue comes from the relative path.

By the way, the use of the sonar-runner to analyze .NET projects is being deprecated. You'll want to have a look at the MSBuild SonarQube Runner that offers very good integration with Team Foundation Server. See the new C# plugin documentation on SonarSource's Wiki: http://docs.sonarqube.org/display/PLUG/C%23+Plugin

EDIT

I just noticed the package name from your logs org.sonar.plugins.csharp.core.CSharpUnitTestResultsProvider. The .core. was present only in outdated versions of the C# plugin (in the 3.x series), and these versions might not support wildcards in report paths. Please upgrade to the latest version.

Dinesh Bolkensteyn
  • 2,971
  • 1
  • 17
  • 20
  • i can't see a message like the one you wrote. i tried to give an absolute path and still no change. I noticed that i get the following warning: "WARN - SCM provider autodetection failed. No SCM provider claims to support this project. Please use sonar.scm.provider to define SCM of your project". does this have anything to do with the unit tests? – Guy Salton Sep 08 '15 at 07:50
  • No that does not relate to the Unit Tests results at all. Could you try a simple scenario, as follow the steps as documented on http://docs.sonarqube.org/display/PLUG/C%23+Unit+Test+Execution+Results+Import ? – Dinesh Bolkensteyn Sep 08 '15 at 13:09
  • It seems that you are using the C# plugin 3.x which is outdated - I've edited my answer – Dinesh Bolkensteyn Sep 08 '15 at 13:15
  • I updated the C# plugin and used the MSBuild SonarQube Runner as you suggested. there is only one problem now, i get an error such as the following:ERROR: Caused by: the folder 'example' does not exist for 'A56FD28C-5687-44E2-8D11-8CB1CE43472A' (base directory = D:\sTFS\27170\Sources\NDM\TestingTools\XmlUtilsTests). – Guy Salton Sep 09 '15 at 15:33
  • I tried to manualy add an empty folder with this name and it solved the problem. is there something I can add to the SonarQube.Analysis.xml or as an argument to the commandline that will ignor this missing folder? I saw some answer regarding java here:[link](https://discuss.gradle.org/t/after-upgrading-from-sonarqube-4-0-to-4-5-1-sonar-runner-is-reporting-a-missing-source-set-directory/1580) – Guy Salton Sep 09 '15 at 15:37
  • I'm glad to hear the initial issue is solved. Could you create a new question, with more details, for that folder problem? Thank you – Dinesh Bolkensteyn Sep 09 '15 at 22:13