0

enter image description hereI am using MSTest for unit test in jenkins. I am able to successfully integrate MSTest plugin with Jenkins. it's performing Unit tests and generating a TestResults.trx file at specific location. Now, I want to pass that file to SonarQube. So, I can see code coverage result on SonarQube. Currently I have Sonar configured without code coverage. It's getting all data without unit tests result. To pass the file to sonar, i found this details on Sonar documents here https://docs.sonarqube.org/pages/viewpage.action?pageId=6389772

I tried to pass arguments /d:sonar.cs.vstest.reportsPaths=%CD%\MSTestResults.trx in Sonar. It didn't work. I have tried multiple times by changing directory and other stuff, It didn't help. Does anyone ever did this before? Why SonarQube plugin in Jenkins is not reading this arguments!!!

I can see in build details that it's reading the agrument which i am passing and it's looking for a file at right location. Still it's not doing anything with that file. as per build details below,

[Test] $ D:\jenkins\tools\hudson.plugins.sonar.MsBuildSQRunnerInstallation\SonarQubeScanner_MSBuild\MSBuild.SonarQube.Runner.exe begin /k:Test_Jenkins /n:Test_Jenkins /v:1.0 /d:sonar.host.url=http://xxxxxxx:9000 ******** /d:sonar.cs.vstest.reportsPaths=D:\jenkins\workspace\Test\TestResults.trx SonarQube Scanner for MSBuild 2.3.2

For second option

I have also tried to use Visual Studio Code metrics ( https://wiki.jenkins-ci.org/display/JENKINS/Visual+Studio+Code+Metrics+Plugin ) to get code coverage. I am able to setup it in jenkins. i can see Code coverage result in jenkins, when i tried to pass that file to sonar, it didn't work.

I am getting metrics.xml file as output with coverage result. I tried to feed it to Sonar by passing argument /d:sonar.cs.vscoveragexml.reportesPaths="${WORKSPACE}\metrics.xml

still it's not working. I am getting result of code coverage as you can see below by visual studio code metrics plugin.enter image description here

Please advice!

Thanks

Meet101
  • 711
  • 4
  • 18
  • 35

1 Answers1

0

I think you are mixing two concepts. In SonarQube, you can provide test execution report, so that you track in SonarQube some statistics about tests execution (number of tests, % success, duration, ...). This is done by passing one of the properties sonar.cs.vstest.reportsPaths, sonar.cs.nunit.reportsPaths or sonar.cs.xunit.reportsPaths. To be honest this is an historical feature, with a very limited interest.

More interesting is to provide test coverage report to SonarQube. This is done by passing one of the properties sonar.cs.ncover3.reportsPaths, sonar.cs.opencover.reportsPaths, sonar.cs.dotcover.reportsPaths or sonar.cs.vscoveragexml.reportsPaths depending on the tool you are using to measure coverage.

  • can you tell me where can i find more details on second concept, how to feed test coverage report to SonarQube? I am using MSTest to perform unit test. – Meet101 Jun 21 '17 at 14:02
  • never mind, I found doc. on test coverage result. https://docs.sonarqube.org/pages/viewpage.action?pageId=6389770 – Meet101 Jun 21 '17 at 14:04
  • Okay, as per documents,I will have to use any tool from the list of 4. When i looked into jenkins plugin store, I found this plugin called "Visual Studio Code metrics" as per document it's saying use Visual Studio Code Coverage https://plugins.jenkins.io/vs-code-metrics. is this the same tool? – Meet101 Jun 21 '17 at 14:22
  • I tried second option by using Visual studio code metrics plugin. i am facing same issue with it also as you can see in edited original post. Please suggest if you have anything. – Meet101 Jun 21 '17 at 16:57