# Number of unit tests is zero

**URL:** <https://community.sonarsource.com/t/number-of-unit-tests-is-zero/26104>\
**Category:** SonarQube Server / Community Build\
**Tags:** sonarqube, scanner, java\
**Created:** [June 9, 2020, 4:13pm UTC](https://community.sonarsource.com/t/number-of-unit-tests-is-zero/26104 "2020-06-09T16:13:12Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![rm25282](https://avatars.discourse-cdn.com/v4/letter/r/d2c977/32.png) [@rm25282](https://community.sonarsource.com/u/rm25282)\
**Post date:** [June 9, 2020, 4:13pm UTC](https://community.sonarsource.com/t/number-of-unit-tests-is-zero/26104/1 "2020-06-09T16:13:12Z")

</div>

Hi,

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

` -Dsonar.junit.reportPaths= **/build/test-results/** /*.xml`

- SQ Version 8.3.1 (build 34397), Jenkins Jenkins 2.231

Is this due to [https://jira.sonarsource.com/browse/SONARSLANG-353](https://jira.sonarsource.com/browse/SONARSLANG-353)?

Many thanks,  
Richard

 ![Screenshot 2020-06-09 at 17.12.06](https://europe1.discourse-cdn.com/sonarsource/uploads/sonarcommunity/original/2X/8/862f9c604b9d292e614302ef9dfda6338256726b.png)

---

<div class="post-metadata">

**Author:** ![OlivierK](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/olivierk/32/11116_2.png) [@OlivierK](https://community.sonarsource.com/u/OlivierK)\
**Post date:** [June 12, 2020, 9:02am UTC](https://community.sonarsource.com/t/number-of-unit-tests-is-zero/26104/2 "2020-06-12T09:02:18Z")

</div>

Hello @rm25282,

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](https://docs.sonarqube.org/latest/analysis/coverage/#header-2) 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.

Olivier

---

<div class="post-metadata">

**Author:** ![pushpa](https://avatars.discourse-cdn.com/v4/letter/p/9de0a6/32.png) [@pushpa](https://community.sonarsource.com/u/pushpa)\
**Post date:** [June 12, 2020, 11:21am UTC](https://community.sonarsource.com/t/number-of-unit-tests-is-zero/26104/4 "2020-06-12T11:21:03Z")

</div>

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?

```auto
sonar.sources=./src
sonar.tests=./src/ __test__

sonar.test.inclusions=./src/ __test__ /*.spec.js
sonar.coverage.exclusions=./src/ __test__ / __snapshots__ /**
sonar.exclusions=./src/assets/*,./node_modules/*,./src/ __test__ /*

sonar.javascript.junit.reportPaths=./junit.xml
sonar.javascript.lcov.reportPaths=./output/coverage/jest/lcov.info
sonar.testExecutionReportPaths=./reports/test-reporter.xml

```

---

<div class="post-metadata">

**Author:** ![rm25282](https://avatars.discourse-cdn.com/v4/letter/r/d2c977/32.png) [@rm25282](https://community.sonarsource.com/u/rm25282)\
**Post date:** [June 17, 2020, 8:58am UTC](https://community.sonarsource.com/t/number-of-unit-tests-is-zero/26104/5 "2020-06-17T08:58:29Z")

</div>

Thanks Olivier for the reply and apologies for taking so long to get back to you.

Indeed I am seeing this in my analysis

Reports path not found or is not a directory: /home/ubuntu/workspace/new\_product\_develop/exporter/ **/build/test-results/** /\*.xml

I will try again with a hardcoded path.

Does this mean I have to list every directory to scan?

---

<div class="post-metadata">

**Author:** ![OlivierK](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/olivierk/32/11116_2.png) [@OlivierK](https://community.sonarsource.com/u/OlivierK)\
**Post date:** [June 19, 2020, 6:50am UTC](https://community.sonarsource.com/t/number-of-unit-tests-is-zero/26104/6 "2020-06-19T06:50:46Z")

</div>

Hello Richard,

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.

Please have a look at the details of all the properties at [https://docs.sonarqube.org/latest/analysis/coverage/#header-2](https://docs.sonarqube.org/latest/analysis/coverage/#header-2)

Olivier

---

<div class="post-metadata">

**Author:** ![rm25282](https://avatars.discourse-cdn.com/v4/letter/r/d2c977/32.png) [@rm25282](https://community.sonarsource.com/u/rm25282)\
**Post date:** [June 19, 2020, 3:39pm UTC](https://community.sonarsource.com/t/number-of-unit-tests-is-zero/26104/7 "2020-06-19T15:39:07Z")

</div>

Hi Olivier,

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

```
-Dsonar.junit.reportPaths=project_dir1/build/test-results, project_dir2/build/test-results

```

and keep adding for every directory that has unit tests in it?

Many thanks,  
Richard

---

<div class="post-metadata">

**Author:** ![OlivierK](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/olivierk/32/11116_2.png) [@OlivierK](https://community.sonarsource.com/u/OlivierK)\
**Post date:** [June 19, 2020, 3:46pm UTC](https://community.sonarsource.com/t/number-of-unit-tests-is-zero/26104/8 "2020-06-19T15:46:44Z")

</div>

Hello Richard,

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…

Olivier

---

<div class="post-metadata">

**Author:** ![Viktor](https://avatars.discourse-cdn.com/v4/letter/v/d6d6ee/32.png) [@Viktor](https://community.sonarsource.com/u/Viktor)\
**Post date:** [July 7, 2020, 3:53pm UTC](https://community.sonarsource.com/t/number-of-unit-tests-is-zero/26104/10 "2020-07-07T15:53:24Z")

</div>

Hi Richard,

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).

---

<div class="post-metadata">

**Author:** ![Margarita\_Nedzelska](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/margarita_nedzelska/32/47493_2.png) [@Margarita\_Nedzelska](https://community.sonarsource.com/u/Margarita_Nedzelska)\
**Post date:** [November 30, 2020, 5:03pm UTC](https://community.sonarsource.com/t/number-of-unit-tests-is-zero/26104/15 "2020-11-30T17:03:02Z")

</div>

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.

Regards,  
Margarita

---

<div class="post-metadata">

**Author:** ![rm25282](https://avatars.discourse-cdn.com/v4/letter/r/d2c977/32.png) [@rm25282](https://community.sonarsource.com/u/rm25282)\
**Post date:** [January 6, 2021, 4:02pm UTC](https://community.sonarsource.com/t/number-of-unit-tests-is-zero/26104/17 "2021-01-06T16:02:19Z")

</div>

Thanks Margarita.

Is this the plugin you mean?

> **[SonarKotlin](https://www.sonarplugins.com/kotlin)**
>
> Code Analyzer for Kotlin

It hasn’t been updated since 2019

---

<div class="post-metadata">

**Author:** ![OlivierK](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/olivierk/32/11116_2.png) [@OlivierK](https://community.sonarsource.com/u/OlivierK)\
**Post date:** [January 6, 2021, 4:47pm UTC](https://community.sonarsource.com/t/number-of-unit-tests-is-zero/26104/18 "2021-01-06T16:47:35Z")

</div>

Hello @rm25282,

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/](https://binaries.sonarsource.com/)  
Specifically you’ll find the different SonarKotlin plugin versions on [https://binaries.sonarsource.com/Distribution/sonar-kotlin-plugin/](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.

Olivier

---

<div class="post-metadata">

**Author:** ![rm25282](https://avatars.discourse-cdn.com/v4/letter/r/d2c977/32.png) [@rm25282](https://community.sonarsource.com/u/rm25282)\
**Post date:** [January 6, 2021, 5:16pm UTC](https://community.sonarsource.com/t/number-of-unit-tests-is-zero/26104/19 "2021-01-06T17:16:32Z")

</div>

Thanks for the prompt response Olivier.

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,  
Richard

---

<div class="post-metadata">

**Author:** ![Margarita\_Nedzelska](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/margarita_nedzelska/32/47493_2.png) [@Margarita\_Nedzelska](https://community.sonarsource.com/u/Margarita_Nedzelska)\
**Post date:** [January 7, 2021, 9:05am UTC](https://community.sonarsource.com/t/number-of-unit-tests-is-zero/26104/20 "2021-01-07T09:05:24Z")

</div>

Hi Richard,

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?

Regards,  
Margarita
