Test Execution Report(s) are not being displayed in SonarCloud

I have a C++ project where I use googletest (gtest) to write my unit tests. After all test executions I have a coverage report (generated with gcovr) and a JUnit test execution report generated with ctest. While the coverage report works, the test executions are not displayed in SonarCloud.

I have made the following attempts:
JUnit report with sonar.junit.reportPaths=reports/junit.xml
"Generic Test Execution Report with sonar.testExecutionReportPaths=dummy_report.xml

When I try to upload the JUnit report, it doesn’t even show me in the sonar-scanner log that the file is being processed. When I upload the dummy report, at least this log entry comes up

INFO: Sensor Generic Test Executions Report
INFO: Parsing <HIDDEN_PATH>/dummy_report.xml
INFO: Imported test execution data for 1 files
INFO: Sensor Generic Test Executions Report (done) | time=5ms

Note: I’m using a “dummy report” since I’m not able to convert JUnit files into the generic test execution format. So here’s my bonus question: does anyone have a tip for me on how to generate my test execution report in a Sonar-friendly way, or at least how to convert my JUnit reports?

Hey there.

sonar.junit.reportPath is only usable for Java files – it is not generic across all languages. That’s why it’s listed under Java in the documentation on Test Coverage & Execution.

I’m not aware of any ready-made converter from JUnit to Generic Execution Data – you may have to search around or build it yourself.

That said, I think this is interesting feedback to pass along to the product team – that gtest supports a JUnit-like test execution report, that is troublesome to import into SonarCloud.

Out of curiosity – how useful is having these results in SonarCloud to you? Is it just for the sake of completeness? In a world where you fail your build if unit tests don’t pass – importing these reports into SonarCloud mostly just lets you keep a running count of how many unit tests your project has, nothing more.

Hi Colin,

thank you very much for your quick reply! For the test executions, I’m concerned with completeness in that I know that the tests were run, what the console output was on failed tests (SonarCloud always runs for me, even if a build fails in Jenkins).
That JUnit reports are not suitable for C++, I can understand so far. But why is the result of my “dummy report” not displayed in the Generic Test Execution format, which is processed?

Hey Jan,

To have any clue there – I think we’d nee to see the dummy test execution report, and an idea of what you’re actually seeing in the SonarCloud UI that indicates it wasn’t read properly (where are you looking?)

This is the content of my dummy_report.xml file:

<testExecutions version="1">
    <file path="test/unit/dummy_test.cpp">
        <testCase name="test1" duration="5" />
        <testCase name="test2" duration="500">
            <skipped message="short message">other</skipped>
        <testCase name="test3" duration="100">
            <failure message="short">stacktrace</failure>
        <testCase name="test4" duration="500">
            <error message="short">stacktrace</error>

In SonarCloud itself I wouldn’t know where to show me the Test Executions, I clicked through all the tabs/menus in the PullRequest. I only see the code coverage, but not the test report.

Ah, there’s something right there. :slight_smile: Test Execution details are only visible on long-lived branches, like the main branch.

Good to know :smiley: Is that somewhere in the documentation? :see_no_evil:

I will get back to you when I have the PR gemerged and then see if it works out

Probably (almost definitely) not. And it doesn’t seem like a tough add. I’ll ping internally.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.