Skip to content

Get test execution metrics

Günter Wirth edited this page May 23, 2014 · 21 revisions

To collect test execution metrics with the C++ Community plugin follow the steps below:

  1. Get an execution report out of your favorite test framework. See Test runners for examples.
  2. Configure your SonarQube project by setting the property sonar.cxx.xunit.reportPath to point to the created report[s] and rerun the analysis.

By default, the JUnitReport format is expected. To import a report in an other format X, set the property sonar.cxx.xunit.xsltURL to a XSLT stylesheet which is able to perform X -> JUnitReport conversion. A couple of ready-made stylesheets are available here:

  • boosttest-1.x-to-junit-1.0.xsl: For transforming Boost-reports
  • cpptestunit-1.x-to-junit-1.0.xsl: For transforming CppTestUnit-reports
  • cppunit-1.x-to-junit-1.0.xsl: For transforming CppUnit-reports

Boost report example

<?xml version="1.0" ?>
<TestLog>
  <TestSuite name="InfrastructureBaseException">
    <TestCase name="ThrowExceptionsTest">
      <Info file="./base.test.boost/exceptiontest.cpp" line="21"><![CDATA[check 'incorrect exception Exception is caught' passed]]></Info>
      <Info file="./base.test.boost/exceptiontest.cpp" line="23"><![CDATA[check 'incorrect exception LocalException is caught' passed]]></Info>
      <TestingTime>2000</TestingTime>
    </TestCase>
  </TestSuite>
</TestLog>
Clone this wiki locally