Analysis of our code base all looks good except the number of unit tests are blank. Screenshot attached. The code and tests are a mixture of kotlin and java.
I have set the following on the gradle command line
If you have Java code then the Junit report should be read, at least partially (I don’t know how the report looks when the it is on a mix of Java and Kotlin code).
I rather suspect that you have the problem because you’re using wildcards in your property. For historical reasons some report properties support wildcards, some don’t - And the documentation on sonar.junit.reportPaths does not mention wildcard support.
You should have a quite clear log in your scanner execution that would explain why the unit test report is not imported (either wildcard not supported it the files will not be found, or potentially error parsing the junit report if the java plugin does not like that there is some kotlin stuff in there).
Send me the scanner logs (preferable in DEBUG mode) if you want me to take a look.
Hi @OlivierK,
i am using Jest, JUnit with sonarQube… in my SonarQube i am not able to see unit tests, below is my sonar properties and log.
Please suggest me on this.
[Test/Sonar] INFO: Parsing /reports/test-reporter.xml
[Test/Sonar] INFO: ------------------------------------------------------------------------
[Test/Sonar] INFO: EXECUTION FAILURE
[Test/Sonar] INFO: ------------------------------------------------------------------------
[Test/Sonar] INFO: Total time: 23.444s
[Test/Sonar] INFO: Final Memory: 31M/117M
[Test/Sonar] INFO: ------------------------------------------------------------------------
[Test/Sonar] ERROR: Error during SonarQube Scanner execution
[Test/Sonar] ERROR: Error during parsing of generic test execution report ‘/reports/test-reporter.xml’. Look at the SonarQube documentation to know the expected XML format.
[Test/Sonar] ERROR: Caused by: Line 3 of report refers to a file which is not configured as a test file: /src/ test /Users.spec.js
[Test/Sonar] ERROR:
[Test/Sonar] ERROR: Re-run SonarQube Scanner using the -X switch to enable full debug logging.
[Pipeline] [Test/Sonar] }
[Test/Sonar] WARN: Unable to locate ‘report-task.txt’ in the workspace. Did the SonarScanner succeeded?
The requirement to list all files is not the same for every language and every test tool. Depending on the language and the tool the unit tests and coverage data is produced differently and we had to adjust. So I cannot give you a response if you don’t tell me what language and what coverage tool we’re talking about.
I see in your properties that you try to set sonar.javascript.junit.reportPaths. This property does not exist. We support junit for Java only. For Javascript you have to use the generic test report format we propose as explained in the doc link below.
Sorry but it looks like someone has posted their question in here too. Our env is a mixture of Kotlin and Java code and unit tests. From what you are saying and the documentation will only the Java ones show up in SonarQube? So can you confirm I need to add this
Junit tests results anyhow relates to number of tests executed, passed, failed and skipped, without limited notion on the code (or language) they were run on. So you only get to totals numbers, nothing more. They will aggregate the Java and Kotlin tests I would assume (although I never tried this configuration I must say)
About your second question, the path is supposed to be relative to the module root directory (if you have a modular Maven project for instance), so if the files have the same name and path relative to the module home, a simple -Dsonar.junit.reportPaths=build/test-results should be enough.
I would need to know more of your project structure to be sure that this simple configuration would work. Worth a try though…
are there any positive results in using a concrete path instead of having wildcards in it?
We have a similar project structure (Android/Kotlin/Gradle) and also have the same problem of missing any test result (nether a test counter nor a test chapter within coverage) even if pass a concrete path for sonar.junit.reportPaths (without wildcards).
Regarding the original topic. Previously surefire reports on Kotlin tests were not supported. In the latest version of Kotlin plugin this feature was added and will be available with the next SonarQube release.
The web site you’re referring to is not by a SonarSource web site, and I should say, not the trust source by any means for analyzers/plugins developed by us.
Since 8.3 SonarSource analyzers are bundled in SonarQube versions so we don’t communicate on plugin individual versions, but simply on SonarQube version (and the improvements on the bundled analyzers).
For customer still on versions older than 8.3 where plugins can be upgraded separately (provided that they are compatible), they can be found on https://binaries.sonarsource.com/
Specifically you’ll find the different SonarKotlin plugin versions on https://binaries.sonarsource.com/Distribution/sonar-kotlin-plugin/ and the most recent one is 1.8.1
And Margarita was right, it is bundled in SonarQube 8.6 released in Dec 2020.
I have upgraded to 8.6 and I still see the unit tests as zero. Is there any specific config I have to update? Or anything I can check to see if they are working or not?
Thanks for your response. It’s hard to say where the problem is without a reproducer. Could you please provide us a link to the repository or just a small reproducer, so I can have a look?