1
votes

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

1

1 Answers

0
votes

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.