How do I show the unit test reports in SonarQube?

Hi,

I’ve setup “JUnit report paths” (Key: sonar.junit.reportPaths) to **/TEST-*.xml in “General Settings”.

In “Overall Code” tab, unit tests show as :

-
Unit Tests

SonarQube Version 9.9 (build 65466)

Thanks,
Nicolas

Hi Nicolas,

Per the docs,

Some properties support the following wildcards in paths. The remarks for properties that support wildcards will mention this fact.

The remarks for sonar.junit.reportPaths, don’t mention that. You’ll need to provide a comma-delimited list of specific paths.

 
HTH,
Ann

Hi,

Good point, I fixed the paths to directories without wildcard.

However, it seems this didn’t change anything.

I see in the logs that the scanner is actually parsing them.

Parsing [/path/to/report.xml]

Thanks for your help,
Nicolas.

Hi Nicolas,

Can you provide your analysis log?

The analysis / scanner log is what’s output from the analysis command. Hopefully, the log you provide - redacted as necessary - will include that command as well.

This guide will help you find them.

 
Ann

Hi,

It says:

Gradle Test Executor 5 finished executing tests.
Finished generating test XML results (0.081 secs) into: /path/to/project/build/test-results
Generating HTML test report...
Finished generating test html results (0.094 secs) into: /path/to/project/build/reports/tests

and later :

INFO: Sensor SurefireSensor [ecocodejavaplugin]
INFO: parsing [/path/to/project/build/test-results]
INFO: Sensor SurefireSensor [ecocodejavaplugin] (done) | time=51ms

Thanks,
Nicolas

Hi Nicolas,

Can we have the full --info analysis log, please?

 
Thx,
Ann

Hi Ann,

Sorry for the delay.
Full log is not disclosable here but I can share what I observed in the output of the SurefireSensor plugin.
There’s nothing at INFO level, but at DEBUG level, 2 types of messages :

- Class not found in resource cache : com.mypackage.MyClassTest (repeated 9 times)
- Resource not found : com.mypackage.MyClassTest

Test classes are compiled with Gradle from src/test/java into build/classes/test and
I have checked the class files were there.
So not sure why somehow the plugin is unable to find them.

Thanks for your help,
Nicolas.

Hi,

I had to set properties sonar.tests to src/test/java :

SonarQube: Unit Test Results Not Shown – RichHewlett.com

Regards,
Nicolas.

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