Error when uploading rest results to sonarqube community edition

Template for a good bug report, formatted with Markdown:

  • versions used SonarQube on-prem community edition
  • error observed
    Error during parsing of the generic coverage report ‘/opt/func_test.xml’. Look at SonarQube documentation to know the expected XML format.
  • steps to reproduce
    Uploading test results output from Junit
  • potential workaround
    None

P.S.: use the #bug:fault sub-category if you’re hitting a specific crash/error , or the #bug:fp sub-category for rules-related behaviour

Hi,

Welcome to the community!

Unfortunately, you’ve given us very little to go in in helping you.

 
Ann

Requirement is: to calculate code coverage from “Functionize” executed test cases.

We are trying to import “junit” data in SonarQube which has the results of executed test cases. We are using the parameter provided by SonarQube i.e. “Dsonar.coverageReportPaths="path/to/file(.xml)”.

We are getting an error i.e. “Error during parsing of the generic coverage report ‘/opt/func_test.xml’. Look at SonarQube documentation to know the expected XML format”.
when we are trying to import the test result generated by the “Functionize” tool.

The coverage is showing as “0.0%” on sonar dashboard. We are using SonarQube version – 8.4.1

Parameters provided to Sonar: Attached Image
Functionize.xml file contains following data: Attached text file

Parameters provided to SonarFunctionize XML.txt (538 Bytes)

Hi,

Does Functionize output its report in the Generic Test Data format?

 
Ann

Hello Ann - No. The output is different and we shared that file yesterday. Our understanding is that SonarQube does support few other XML formats.

If that’s not the case, we will go back to Functionize to make a change and provide output in the test data format you have shared.

Regards.

Hi,

The sonar.coverageReportPaths parameter is specifically for passing in data in the Generic Test Data format. Full list of coverage parameters here.

 
Ann

I am trying to get the test execution report on sonarqube the coverage is successfull but not the unit test.
My sonarqube is running inside docker container. I have generated the test execution data “mocha-sonarqube-reporter” and recived the data in xml format.
used nyc for coverage report.
the sonarqube cmd is as follows:

The sonar logs are as follows:
INFO: Scanner configuration file: /var/jenkins_home/tools/hudson.plugins.sonar.SonarRunnerInstallation/extensure-sonar-scanner/conf/sonar-scanner.properties
INFO: Project root configuration file: NONE
INFO: SonarScanner 4.5.0.2216
INFO: Java 1.8.0_272 AdoptOpenJDK (64-bit)
INFO: Linux 4.19.76-linuxkit amd64
INFO: User cache: /root/.sonar/cache
INFO: Scanner configuration file: /var/jenkins_home/tools/hudson.plugins.sonar.SonarRunnerInstallation/extensure-sonar-scanner/conf/sonar-scanner.properties
INFO: Project root configuration file: NONE
INFO: Analyzing on SonarQube server 8.4.1
INFO: Default locale: “en_US”, source code encoding: “UTF-8” (analysis is platform dependent)
WARN: SonarScanner will require Java 11 to run starting in SonarQube 8.x
INFO: Load global settings
INFO: Load global settings (done) | time=64ms
INFO: Server id: BF41A1F2-AXZHlvEOpdl3jkIdcHbq
INFO: User cache: /root/.sonar/cache
INFO: Load/download plugins
INFO: Load plugins index
INFO: Load plugins index (done) | time=35ms
INFO: Load/download plugins (done) | time=62ms
INFO: Process project properties
INFO: Process project properties (done) | time=7ms
INFO: Execute project builders
INFO: Execute project builders (done) | time=3ms
INFO: Project key: Sonar_Extensure_test_11
INFO: Base dir: /var/jenkins_home/workspace/sonar_result_test
INFO: Working dir: /var/jenkins_home/workspace/sonar_result_test/.scannerwork
INFO: Load project settings for component key: ‘Sonar_Extensure_test_11’
INFO: Load project settings for component key: ‘Sonar_Extensure_test_11’ (done) | time=19ms
INFO: Load quality profiles
INFO: Load quality profiles (done) | time=52ms
INFO: Auto-configuring with CI ‘Jenkins’
INFO: Load active rules
INFO: Load active rules (done) | time=985ms
INFO: Indexing files…
INFO: Project configuration:
INFO: 41 files indexed
INFO: 0 files ignored because of scm ignore settings
INFO: Quality profile for ts: Sonar way
INFO: ------------- Run sensors on module Sonar_Extensure_test_11
INFO: Load metrics repository
INFO: Load metrics repository (done) | time=21ms
INFO: Sensor SonarCSS Rules [cssfamily]
INFO: No CSS, PHP, HTML or VueJS files are found in the project. CSS analysis is skipped.
INFO: Sensor SonarCSS Rules [cssfamily] (done) | time=1ms
INFO: Sensor JaCoCo XML Report Importer [jacoco]
INFO: ‘sonar.coverage.jacoco.xmlReportPaths’ is not defined. Using default locations: target/site/jacoco/jacoco.xml,target/site/jacoco-it/jacoco.xml,build/reports/jacoco/test/jacocoTestReport.xml
INFO: No report imported, no coverage information will be imported by JaCoCo XML Report Importer
INFO: Sensor JaCoCo XML Report Importer [jacoco] (done) | time=3ms
INFO: Sensor SonarJS Coverage [javascript]
INFO: Analysing [/var/jenkins_home/workspace/sonar_result_test/./coverage/lcov.info]
INFO: Load project repositories
INFO: Load project repositories (done) | time=18ms
WARN: Could not resolve 3 file paths in [/var/jenkins_home/workspace/sonar_result_test/./coverage/lcov.info]
WARN: First unresolved path: coverage/lcov-report/block-navigation.js (Run in DEBUG mode to get full list of unresolved paths)
INFO: Sensor SonarJS Coverage [javascript] (done) | time=76ms
INFO: Sensor TypeScript analysis [javascript]
INFO: Using TypeScript at: ‘/var/jenkins_home/workspace/sonar_result_test/node_modules’
INFO: Found 1 tsconfig.json file(s): [/var/jenkins_home/workspace/sonar_result_test/tsconfig.json]
INFO: 40 source files to be analyzed
INFO: Analyzing 40 files using tsconfig: /var/jenkins_home/workspace/sonar_result_test/tsconfig.json
WARN: You are using version of TypeScript 3.9.9 which is not officially supported; supported versions >=3.2.1 <3.8.0
INFO: 40/40 source files have been analyzed
INFO: Sensor TypeScript analysis [javascript] (done) | time=5156ms
INFO: Sensor JavaXmlSensor [java]
INFO: Sensor JavaXmlSensor [java] (done) | time=1ms
INFO: Sensor HTML [web]
INFO: Sensor HTML [web] (done) | time=2ms
INFO: Sensor SonarTS [typescript]
INFO: Since SonarTS v2.0, TypeScript analysis is performed by SonarJS analyzer v6.0 or later. No TypeScript analysis is performed by SonarTS.
INFO: Sensor SonarTS [typescript] (done) | time=0ms
INFO: Sensor Generic Test Executions Report
INFO: Parsing /var/jenkins_home/workspace/sonar_result_test/xunit.xml
INFO: Imported test execution data for 0 files
INFO: Test execution data ignored for 9 unknown files, including:
/var/jenkins_home/workspace/sonar_result_test/lib/tests/bots/dialogAndWelcomeBot.test.js
/var/jenkins_home/workspace/sonar_result_test/lib/tests/dialogs/bookingDialog.test.js
/var/jenkins_home/workspace/sonar_result_test/lib/tests/dialogs/cancelAndHelpDialog.test.js
/var/jenkins_home/workspace/sonar_result_test/lib/tests/dialogs/dateResolverDialog.test.js
/var/jenkins_home/workspace/sonar_result_test/lib/tests/dialogs/emailValidator.test.js
INFO: Sensor Generic Test Executions Report (done) | time=43ms
INFO: ------------- Run sensors on project
INFO: Sensor Zero Coverage Sensor
INFO: Sensor Zero Coverage Sensor (done) | time=4ms
INFO: CPD Executor 3 files had no CPD blocks
INFO: CPD Executor Calculating CPD for 37 files
INFO: CPD Executor CPD calculation finished (done) | time=32ms
INFO: Analysis report generated in 62ms, dir size=286 KB
INFO: Analysis report compressed in 88ms, zip size=131 KB
INFO: Analysis report uploaded in 22ms
INFO: ANALYSIS SUCCESSFUL, you can browse http://192.168.157.161:9000/dashboard?id=Sonar_Extensure_test_11
INFO: Note that you will be able to access the updated dashboard once the server has processed the submitted analysis report
INFO: More about the report processing at http://192.168.157.161:9000/api/ce/task?id=AXjGF56xh6OZzIOB-uWs
INFO: Analysis total time: 8.455 s
INFO: ------------------------------------------------------------------------
INFO: EXECUTION SUCCESS
INFO: ------------------------------------------------------------------------
INFO: Total time: 9.134s
INFO: Final Memory: 17M/253M
INFO: ------------------------------------------------------------------------

Not able to understand why this is happening:
INFO: Test execution data ignored for 9 unknown files, including:
/var/jenkins_home/workspace/sonar_result_test/lib/tests/bots/dialogAndWelcomeBot.test.js
/var/jenkins_home/workspace/sonar_result_test/lib/tests/dialogs/bookingDialog.test.js
/var/jenkins_home/workspace/sonar_result_test/lib/tests/dialogs/cancelAndHelpDialog.test.js
/var/jenkins_home/workspace/sonar_result_test/lib/tests/dialogs/dateResolverDialog.test.js
/var/jenkins_home/workspace/sonar_result_test/lib/tests/dialogs/emailValidator.test.js

The coverage is visible but the unit test are not…

How do i get the unit test result on sonarqube
Please let me know what is missing here