Unable to upload the Generic Test Execution XML file to SonarQube server


We have a solution that is written in C++ language and uses Catch2 as the testing framework. Using the functionality mentioned in this link: Catch2/ci-and-misc.md at devel · catchorg/Catch2 · GitHub, we were able to create an XML file that follows the Generic Test Execution format. Then using the sonar.testExecutionReportPaths argument in the SonarScanner.MSBuild.exe begin command, I tried to upload the generated XML to our SonarQube server but it doesn’t show anything. There is no error or success message in the logs.

Repro steps

  1. Generate the generic test execution XML file using the following command provided by the catch2 framework, in the Post Build event of the solution.:
    NativeTests.exe -r sonarqube -o NativeTests.xml
  2. Pass the location of the file in SonarScanner.MSBuild.exe begin command as follows:
    C:\SonarQube\bin\SonarScanner.MSBuild.exe begin /k:NativeTests.sln /n:NativeTests.sln /v:20.1.0 /d:sonar.language=c++ /d:sonar.sources=aa /d:sonar.testExecutionReportPaths=C:\Temp\NativeTests.xml /d:sonar.verbose=true
  3. Perform the build and run the SonarScanner.MSBuild.exe end command as follows:
    C:\SonarQube\bin\SonarScanner.MSBuild.exe end

Expected behavior

I expected that the test cases present in the XML get imported to our local SonarQube Server.

Actual behavior

SonarScanner.MSBuild.exe fails after it starts to parse the XML file. There is no other error shown in the logs. Following is shown in the log file:

09:13:19.527 INFO: Sensor JaCoCo XML Report Importer [jacoco] (done) | time=0ms
09:13:19.527 INFO: Sensor Generic Test Executions Report
09:13:19.528 INFO: Parsing C:\Temp\NativeTests.xml
09:13:21.599 INFO: ------------------------------------------------------------------------
09:13:21.599 INFO: ------------------------------------------------------------------------
09:13:21.599 INFO: Total time: 7:00.190s
09:13:21.872 INFO: Final Memory: 30M/1762M
09:13:21.872 INFO: ------------------------------------------------------------------------
Process returned exit code 1

I also tried to navigate the code present in sonarqube/GenericTestExecutionSensor.java at master · SonarSource/sonarqube · GitHub and sonarqube/GenericTestExecutionReportParser.java at 88131a33e07fe611f32883079614d1e768f60076 · SonarSource/sonarqube · GitHub but couldn’t find anything that would tell me if there is any issue with the XML that I am providing in SonarScanner begin command.

Known workarounds

None at the moment

Related information

  • SonarScanner for MSBuild version:
  • SonarQube server version: Community Edition - Version 7.9.1 (build 27448)
  • Languages in your solution: C++

Unfortunately, due to company policies, I won’t be able to attach the solution. I have attached the XML file as a ZIP file. You will be able to get the XML file after unzipping the ZIP.
NativeTests.zip (483 Bytes)

Things that I tried but still didn’t work

  1. Removing the XML comment
  2. Changing the encoding of the file
  3. Reducing the number of test cases to 1
  4. Changing the slashes in the file path
  5. Using a relative path than an absolute path in the file path.

Thanks in advance.

I had previously posted this on SonarSource/sonar-scanner-msbuild GitHub: Unable to upload the Generic Test Execution XML file to SonarQube server · Issue #877 · SonarSource/sonar-scanner-msbuild · GitHub


Welcome to the community!

Your version is past EOL. You should upgrade to either the latest version or the current LTS at your earliest convenience. Your upgrade path is:

7.9.1 → 8.9.8 → 9.4 (last step optional)

You may find the Upgrade Guide and the LTS-to-LTS Upgrade Notes helpful. If you have questions about upgrading, feel free to open a new thread for that here.

Regarding your issue, I have a few factoids that might shed some light:

  • Community Edition doesn’t support C++
  • The Generic Test import doesn’t support “unknown” languages (which C++ is in a Community Edition context)