Skip to content

sonar.cxx.vstest.reportPaths

guwirth edited this page Mar 10, 2021 · 4 revisions

Overview

Sensor to read reports from the VSTest testing framework . The Visual Studio Test Platform is an open and extensible test platform that enables running tests, collect diagnostics data and report results. The Test Platform supports running tests written in various test frameworks, and using a pluggable adapter model.

Meanwhile, VSTest support is part of SonarQube. If possible sonar.cs.vstest.reportsPaths should be used.

Note: The cxx plugin itself does not run any tools, you have to do that yourself beforehand. The sensor only reads the report generated by a tool!

Supported versions

Create report

In order to generate a fitting report, make sure:

  • that the paths in the report matches the sonar.sources and sonar.tests lists in sonar-project.properties
  • the path can be absolute or relative to the project base directory

VSTest.Console.exe is the command-line tool to run tests.

Sample command lines:

vstest.console.exe myTestFile.dll  /Logger:trx ...

Example of a report file

If the tool was executed successfully, a .TRX report like the example below should be generated:

<?xml version="1.0" encoding="UTF-8"?>
<TestRun id="0ecff956-7215-452f-9ce6-2b6d45870188" name="vagrant@WIN7PRO64 2014-06-11 15:48:58" runUser="WIN7PRO64\vagrant" xmlns="http://microsoft.com/schemas/VisualStudio/TeamTest/2010">
  <Times creation="2016-03-14T17:04:31.0752743+01:00" queuing="2016-03-14T17:04:31.4447480+01:00" start="2016-03-14T17:04:31.1+01:00" finish="2016-03-14T17:04:31.9162137+01:00" />
  <ResultSummary outcome="Failed">
    <Counters total="43" executed="42" passed="14" failed="2" error="3" timeout="5" aborted="7" inconclusive="11" passedButRunAborted="0" notRunnable="0" notExecuted="1" disconnected="0" warning="0" completed="0" inProgress="0" pending="0" />
  </ResultSummary>
</TestRun>

Configure cxx plugin

  1. First check if the file extensions read in by the cxx plugin are set (sonar.cxx.file.suffixes).
  2. That the paths in the report matches the sonar.sources and sonar.tests lists in sonar-project.properties.
  3. Set the analysis parameter sonar.cxx.vstest.reportPaths in the configuration file sonar-project.properties of your project. The Report Paths link describes the configuration options.
  4. Execute the SonarScanner to transfer the project with the report to the SonarQube Server.

Sample for sonar-project.properties:

sonar.cxx.vstest.reportPaths=report.trx

Troubleshooting

Clone this wiki locally