# Test results are not being published to sonarcloud

**URL:** <https://community.sonarsource.com/t/test-results-are-not-being-published-to-sonarcloud/27509>\
**Category:** SonarQube Cloud\
**Tags:** github-actions, scala, github, sonarqube-cloud\
**Created:** [July 2, 2020, 10:41pm UTC](https://community.sonarsource.com/t/test-results-are-not-being-published-to-sonarcloud/27509 "2020-07-02T22:41:55Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![gastonschabas](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/gastonschabas/32/13075_2.png) [@gastonschabas](https://community.sonarsource.com/u/gastonschabas)\
**Post date:** [July 2, 2020, 10:41pm UTC](https://community.sonarsource.com/t/test-results-are-not-being-published-to-sonarcloud/27509/1 "2020-07-02T22:41:55Z")

</div>

Hi everyone. I’m facing the following issue. I have a github repo that runs github actions when a new PR is created. It runs different sbt commands such as linting, unit testing, etc. For some reason I can’t publish my results to Sonar Cloud. The following list contains the details of the context where this is happening.

- SonarCloud project [https://sonarcloud.io/dashboard?id=gastonschabas\_rumble-on-scala](https://sonarcloud.io/dashboard?id=gastonschabas_rumble-on-scala)
- GitHub Public Repo [https://github.com/gastonschabas/rumble-on-scala/](https://github.com/gastonschabas/rumble-on-scala/)
- Github Action to run unit test
- Tried publish the test results to sonarcloud using this github action [https://github.com/SonarSource/sonarcloud-github-action](https://github.com/SonarSource/sonarcloud-github-action). Here is the PR [https://github.com/gastonschabas/rumble-on-scala/pull/12/files](https://github.com/gastonschabas/rumble-on-scala/pull/12/files)
- Tried to publish rest results using sbt-sonar. Here is the PR [https://github.com/gastonschabas/rumble-on-scala/pull/13/files](https://github.com/gastonschabas/rumble-on-scala/pull/13/files)

Also I tried to analyse the code using the automatic analysis, but didn’t work.

---

<div class="post-metadata">

**Author:** ![mickaelcaro](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/mickaelcaro/32/4147_2.png) [@mickaelcaro](https://community.sonarsource.com/u/mickaelcaro)\
**Post date:** [July 3, 2020, 5:48am UTC](https://community.sonarsource.com/t/test-results-are-not-being-published-to-sonarcloud/27509/2 "2020-07-03T05:48:04Z")

</div>

Hi @gastonschabas and welcome to the community !

I think there’s a typo on your scala coverage property :

Instead of sonar.scala.scoverage.reportPath it should be : sonar.scala.coverage.reportPaths

See our doc for more explanations : [https://sonarcloud.io/documentation/analysis/coverage/](https://sonarcloud.io/documentation/analysis/coverage/)

HTH,  
Mickaël

---

<div class="post-metadata">

**Author:** ![gastonschabas](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/gastonschabas/32/13075_2.png) [@gastonschabas](https://community.sonarsource.com/u/gastonschabas)\
**Post date:** [July 4, 2020, 4:02pm UTC](https://community.sonarsource.com/t/test-results-are-not-being-published-to-sonarcloud/27509/3 "2020-07-04T16:02:11Z")

</div>

Hi @mickaelcaro, thanks for your answer. I fixed the typo that I had for scala coverage path in PR [https://github.com/gastonschabas/rumble-on-scala/pull/13](https://github.com/gastonschabas/rumble-on-scala/pull/13) but I’m still getting no results. The log of the pipeline executed when I pushed the changes shows that the results were published here [https://sonarcloud.io/dashboard?id=gastonschabas\_rumble-on-scala&pullRequest=13](https://sonarcloud.io/dashboard?id=gastonschabas_rumble-on-scala&pullRequest=13), but nothing has changed.

---

<div class="post-metadata">

**Author:** ![mickaelcaro](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/mickaelcaro/32/4147_2.png) [@mickaelcaro](https://community.sonarsource.com/u/mickaelcaro)\
**Post date:** [July 6, 2020, 5:41am UTC](https://community.sonarsource.com/t/test-results-are-not-being-published-to-sonarcloud/27509/4 "2020-07-06T05:41:43Z")

</div>

Hi @gastonschabas  
I probably don’t have access but do you see something in the “Code” tab of your project for your PR ?

If not, i would try first to have some code and LOCs detected by SonarCloud before digging into that coverage issue.

---

<div class="post-metadata">

**Author:** ![gastonschabas](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/gastonschabas/32/13075_2.png) [@gastonschabas](https://community.sonarsource.com/u/gastonschabas)\
**Post date:** [July 7, 2020, 12:21am UTC](https://community.sonarsource.com/t/test-results-are-not-being-published-to-sonarcloud/27509/5 "2020-07-07T00:21:00Z")

</div>

Hi @mickaelcaro  
I added and pushed new code to each PR  
this time sonar code analysis was triggered but it failed. Looks like the new code was detected, but test weren’t. I mean, both new methods are marked as uncovered by tests. If you check the tests, I added coverage for one of them.

- PR 12 [https://github.com/gastonschabas/rumble-on-scala/pull/12](https://github.com/gastonschabas/rumble-on-scala/pull/12)

- results in sonar [https://sonarcloud.io/dashboard?id=gastonschabas\_rumble-on-scala&pullRequest=12](https://sonarcloud.io/dashboard?id=gastonschabas_rumble-on-scala&pullRequest=12)

- PR 13 [https://github.com/gastonschabas/rumble-on-scala/pull/13](https://github.com/gastonschabas/rumble-on-scala/pull/13)

- results in sonar [https://sonarcloud.io/dashboard?id=gastonschabas\_rumble-on-scala&pullRequest=13](https://sonarcloud.io/dashboard?id=gastonschabas_rumble-on-scala&pullRequest=13)

---

<div class="post-metadata">

**Author:** ![mickaelcaro](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/mickaelcaro/32/4147_2.png) [@mickaelcaro](https://community.sonarsource.com/u/mickaelcaro)\
**Post date:** [July 7, 2020, 5:38am UTC](https://community.sonarsource.com/t/test-results-are-not-being-published-to-sonarcloud/27509/6 "2020-07-07T05:38:47Z")

</div>

Ok i think i got it. Seeing the latest log

```auto
00:13:38.413 WARN: Fail to resolve 2 file(s). No coverage data will be imported on the following file(s): /home/runner/work/rumble-on-scala/rumble-on-scala/src/main/scala/com/gaston/adder/Adder.scala;/home/runner/work/rumble-on-scala/rumble-on-scala/src/main/scala/com/gaston/adder/Subtractor.scala

```

It seems that there is a mismatch between the paths that are inside the coverage report vs what we detected with the scanner.

Could you maybe check on that side ?

Thanks.

---

<div class="post-metadata">

**Author:** ![gastonschabas](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/gastonschabas/32/13075_2.png) [@gastonschabas](https://community.sonarsource.com/u/gastonschabas)\
**Post date:** [July 13, 2020, 1:57am UTC](https://community.sonarsource.com/t/test-results-are-not-being-published-to-sonarcloud/27509/7 "2020-07-13T01:57:36Z")

</div>

Hi @mickaelcaro. I found that `sonar.tests` where pointing to a wrong path. I fixed that and now the `WARN` is not being showed anymore. But sonar report still saying that there is no coverage. Not sure what am I missing here.  
I run sonarqube community 8.4 in my localhost using docker and the report generated was ok. For some reason in my local environment, `sonar-project.properties` is not being detected, so I had to send the parameters through command line to make it work. Even though I tried to do the same in github, but it looks like it doesn’t make any difference. It stills saying no lines were covered by the tests.

---

<div class="post-metadata">

**Author:** ![gastonschabas](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/gastonschabas/32/13075_2.png) [@gastonschabas](https://community.sonarsource.com/u/gastonschabas)\
**Post date:** [August 26, 2020, 9:56pm UTC](https://community.sonarsource.com/t/test-results-are-not-being-published-to-sonarcloud/27509/8 "2020-08-26T21:56:57Z")

</div>

Hey @mickaelcaro After trying different things, I could solve it. Not sure why [https://github.com/SonarSource/sonarcloud-github-action](https://github.com/SonarSource/sonarcloud-github-action) is not working (maybe there is an issue with sbt or scala, not sure). Using the following sbt plugin [https://sonar-scala.com/docs/setup/sbt-sonar/](https://sonar-scala.com/docs/setup/sbt-sonar/) was the only thing that worked. I have to generate a token in sonar cloud and add a new key named SONAR\_TOKEN to my secrets in my github repo. This is how my github workflow yaml file looks

```
name: Continious Integration
on:
  pull_request:
    branches:
      - master
    paths-ignore:
      - '**.md'
jobs:
  build:
    runs-on: ubuntu-latest
    steps:
    - name: Checkout
      uses: actions/checkout@v2
      with:
        fetch-depth: 0
    - name: Cache SBT
      uses: actions/cache@v2
      with:
        path: |
          ~/.ivy2/cache
          ~/.sbt
        key: ${{ runner.os }}-sbt-${{ hashFiles('**/build.sbt') }}
    - name: Setup Scala
      uses: actions/setup-java@v1
      with:
        java-version: 11
    - name: Test with Coverage / Static code analyse / Code style
      env:
        GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
      run: |
        sbt \
        -Dsonar.host.url=https://sonarcloud.io \
        -Dsonar.organization=gastonschabas \
        -Dsonar.projectKey=gastonschabas_rumble-on-scala \
        -Dsonar.sources=src/main/scala \
        -Dsonar.tests=src/test/scala \
        -Dsonar.scala.scalastyle.reportPaths=target/scalastyle-result.xml \
        -Dsonar.scala.scapegoat.reportPaths=target/scala-2.12/scapegoat-report/scapegoat-scalastyle.xml \
        -Dsonar.scala.coverage.reportPaths=target/scala-2.12/scoverage-report/scoverage.xml \
        clean compile coverage test coverageReport scapegoat scalastyle scalafmtCheckAll scalafmtSbtCheck sonarScan

```

Thanks for your help and sorry for my late answer

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/system/32/78532_2.png) [@system](https://community.sonarsource.com/u/system)\
**Post date:** [September 2, 2020, 9:56pm UTC](https://community.sonarsource.com/t/test-results-are-not-being-published-to-sonarcloud/27509/9 "2020-09-02T21:56:58Z")

</div>

Closed on September 2, 2020, 9:56pm UTC

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