2
votes

Environment : SonarQube 5.6 - SonarQube Runner 2.4 - MSBuild.SonarQube.Runner-2.0 - TFS 2015 - C#6

I've a Visual Studio 2015 solution with C# 6 projects and unit tests. On my TFS 2015 server, I define a build (task-based, not xaml). On my build, I've added the following steps : - SonarQube for MSBuild - Begin Analysis. - Visual Studio Test - SonarQube for MSBuild - End Analysis.

Everything run fine (build, unit tests execution, code coverage, analysis results based on SonarLint, ... except that I don't see the tests results in the Sonar report (code coverage is there !).

I've tried to add some parameters : - begin analysis : I've added : /d:sonar.cs.vstest.reportsPaths=../TestResults/*.trx - vstests console : /Logger:trx

In the end analysis logs, I see this :

Attempting to locate a test results (.trx) file... Located a test results file: E:\agent_work\3\TestResults\tests_results_2016-06-23 14_07_22.trx Sensor org.sonar.plugins.csharp.CSharpUnitTestResultsProvider$CSharpUnitTestResultsImportSensor Sensor org.sonar.plugins.csharp.CSharpUnitTestResultsProvider$CSharpUnitTestResultsImportSensor (done) | time=0ms

Any idea why I see always Unit tests=0 in the Sonar report ?

1

1 Answers

0
votes

You need to provide full path to the .trx file. With below changes in begin analysis and try it again.

Change

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

To

 /d:sonar.cs.vstest.reportsPaths=../TestResults/Mytest.trx