I 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.
Please advice!
Thanks