3

I've configured my Jenkins build server to analyze my code and post to my SonarQube server. I have successfully posted the scan results but the Test and VS Code Coverage results do not get posted to SonarQube.

I've added the required additional arguments to the SonarQube scanner for MSBuild Begin Analysis step

/d:sonar.cs.vstest.reportsPaths="<absolute path to workspace>\TestResults\*.trx"
/d:sonar.cs.vscoveragexml.reportsPaths="<absolute path to workspace>\VisualStudio.coveragexml"
/d:sonar.verbose="true"

I've configured build steps to perform the Coverage Collection through CodeCoverage.exe as expressed in the SonarQube wiki pages for importing Code Coverage and Unit Test Execution results.

I've also observed in the console output, SonarQube Scanner is parsing both files. i.e.

INFO  - Parsing the Visual Studio Test Results file <absolute path>.trx

and

INFO  - Parsing the Visual Studio coverage XML report <absolute path>.coveragexml

What can I do to identify and resolve the problem to import the test and coverage results?

demaskey
  • 31
  • 3
  • I am facing a similar problem, using TFS 2015 vNext type of build. I added the pre and post steps, and it automatically picks the coverage absolute paths but does not upload any test/coverage data to Sonar server (i only get code duplication). I am using C++ community plug-in, is that your case? the only thing i can point to is: http://docs.sonarqube.org/pages/viewpage.action?pageId=6389770 – Jon Apr 14 '16 at 16:27
  • I'm using the C# plugin. I found some success switching from VS Test Code Coverage to OpenCover. The scanner uploads coverage for my CS files and it uploads the test result totals, i.e. Total Tests, Total Tests Passed, Total Tests Failed. But it doesn't upload which tests passed or failed. – demaskey Apr 14 '16 at 20:54
  • @cdemaskey- In my case, i am not getting .coveragexml file from VSTest plugin. I am getting only .trx file. I did check on Enable Code coverage option. Still not getting. Any idea? You haven't find any solution to work with VSTest and send result files to sonarqube yet? – Meet101 Jun 22 '17 at 18:05
  • @cdemaskey - In my case it's not reading both arguments itself. **/d:sonar.cs.vstest.reportsPaths** **/d:sonar.cs.vscoveragexml.reportsPaths** it's reading verbose arguments but not above two. Please advice! – Meet101 Jun 22 '17 at 18:19
  • @Meet101 I'm sorry to hear you're struggling with this issue too. Ultimately, I switched over to MSTest.exe as the test runner wrapped inside OpenCover for code coverage. I was able to settle for this solution since it gave me more historical info than before but I was never able to get individual test results imported into SonarQube. – demaskey Jun 22 '17 at 23:50

0 Answers0