Test Execution report for JavaScript not picked up

Hi,

I have a maven project that has two sub modules, 1 with java and 1 with javascript. The sonar plugin for maven works great in picking up a lot of metrics, but it fails to find the test execution report from jest.

I have jest configured to use testResultsProcessor: "jest-sonar-reporter". I can see the XML report.
In the pom, I have:

    <sonar.sources>pom.xml,src/main/js</sonar.sources>
    <sonar.tests>src/test/js</sonar.tests>
    <sonar.test.inclusions>**/*.test.js</sonar.test.inclusions>
    <sonar.testExecutionReportPaths>${project.build.directory}/jest-reports/test-report.xml</sonar.testExecutionReportPaths>
    <sonar.javascript.lcov.reportPaths>${project.build.directory}/jest-coverage/lcov.info</sonar.javascript.lcov.reportPaths>

The lcov report is picked up nicely, but the Test Execution Report is not show.
I also do not see the GenericTestExecutionSensor kick in.

Any help would be greatly appreciated! :slight_smile:

  • GitHub
  • Circle CI
    *mvn -B -ntp -T 1C jacoco:merge jacoco:report sonar:sonar -Dsonar.projectKey=Onegini_onegini-customer-dashboard -Dsonar.organization=onegini -Dsonar.host.url=${SONAR_HOST_URL} -Dsonar.login=${SONAR_LOGIN} -P circleci --settings 'maven-settings.xml' ${GIT_BASED_VERSION_PARAMS}
  • java + javascript

Welcome to the community!

Just to be clear, what exactly are you expecting to see?

Can you please share the relevant log output, showing that the scanner picked up the test report and coverage files?

I would like to see the number of test in the javascript module. Currently only the tests in the java module are shown.

The output of the scanner should have some lines about the processing of the report files, and if there is an issue with them. Please take a look at the output of the scanner. Let us know what you find. If you still need help, then please also include the scanner output in your response.

This is the relevant portion of the output of the scanner:

34914 [INFO] Indexing files of module 'xxx :: Frontend'
34914 [INFO]   Base dir: /home/********/project/xxx
34915 [INFO]   Source paths: pom.xml, src/main/js
34915 [INFO]   Test paths: src/test/js
34915 [INFO]   Excluded sources: **/*.test.js
34916 [INFO]   Included tests: **/*.test.js
[snip]
42579 [INFO] ------------- Run sensors on module xxx :: Frontend
42733 [INFO] Sensor SonarCSS Metrics [cssfamily]
42747 [INFO] Sensor SonarCSS Metrics [cssfamily] (done) | time=14ms
42748 [INFO] Sensor SonarCSS Rules [cssfamily]
44978 [INFO] Using Node.js executable /home/********/project/***/node/node from property sonar.nodejs.executable.
45231 [INFO] 1 source files to be analyzed
45368 [INFO] 1/1 source files have been analyzed
45368 [INFO] Sensor SonarCSS Rules [cssfamily] (done) | time=2620ms
45368 [INFO] Sensor JavaXmlSensor [java]
45369 [INFO] 1 source files to be analyzed
45376 [INFO] Sensor JavaXmlSensor [java] (done) | time=8ms
45377 [INFO] 1/1 source files have been analyzed
45377 [INFO] Sensor HTML [web]
45377 [INFO] Sensor HTML [web] (done) | time=0ms
45378 [INFO] Sensor XML Sensor [xml]
45378 [INFO] 1 source files to be analyzed
45383 [INFO] Sensor XML Sensor [xml] (done) | time=4ms
45383 [INFO] 1/1 source files have been analyzed
45383 [INFO] Sensor JaCoCo XML Report Importer [jacoco]
45384 [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
45384 [INFO] No report imported, no coverage information will be imported by JaCoCo XML Report Importer
45384 [INFO] Sensor JaCoCo XML Report Importer [jacoco] (done) | time=1ms
45385 [INFO] Sensor JavaScript analysis [javascript]
49217 [INFO] Using Node.js executable /home/********/project/***/node/node from property sonar.nodejs.executable.
49635 [INFO] 44 source files to be analyzed
51024 [INFO] 44/44 source files have been analyzed
51024 [INFO] Java-based frontend sensor [javascript]
51030 [INFO] 44 source files to be analyzed
51648 [INFO] Java-based frontend sensor [javascript] (done) | time=624ms
51648 [INFO] 44/44 source files have been analyzed
51648 [INFO] Sensor JavaScript analysis [javascript] (done) | time=6263ms
51649 [INFO] Sensor JavaScript/TypeScript Coverage [javascript]
51650 [INFO] Analysing [/home/********/project/***/target/jest-coverage/lcov.info, /home/********/project/***/target/cypress-coverage/lcov.info]
51671 [INFO] Sensor JavaScript/TypeScript Coverage [javascript] (done) | time=22ms
51671 [INFO] Sensor ThymeLeaf template sensor [securityjavafrontend]
51672 [INFO] Sensor ThymeLeaf template sensor [securityjavafrontend] (done) | time=1ms
51672 [INFO] ------------- Run sensors on module xxx

With sonar.testExecutionReportPaths=path/to/report.xml present, the log looks like this in my tests:

INFO: Sensor ThymeLeaf template sensor [securityjavafrontend]
INFO: Sensor ThymeLeaf template sensor [securityjavafrontend] (done) | time=0ms
INFO: Sensor Generic Test Executions Report
INFO: Parsing path/to/report.xml
INFO: Imported test execution data for 0 files
INFO: Sensor Generic Test Executions Report (done) | time=8ms
INFO: Sensor JavaSecuritySensor [security]

That is, there should be some lines about “Sensor Generic Test Executions Report” in between ThymeLeaf and JavaSecuritySensor. These lines are not present when the sonar.testExecutionReportPaths setting is not present.

As a sanity check, you could try to run the mvn command with the sonar.testExecutionReportPaths setting explicitly included on the command line, like this:

mvn verify sonar:sonar -Dsonar.testExecutionReportPaths=path/to/report.xml

(This was not necessary in my tests. It worked perfectly fine to include the property definition in the pom.xml as you did, so the situation remains strange.)

That property is set in the project pom.xml file -as mentioned in the ticket-, but the output is not shown. Is there any way to diagnose this problem?

I think this issue is relevant: https://jira.sonarsource.com/browse/SONAR-11530
Apparently the configuration has to be on project level, not module level.

1 Like

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