Sonarqube "not covered by tests" error for new code lines not covered in test file

Hi All,
We are facing one issue in our project.
The new code changes written in test case file is not covered by sonar, but the new code changes are committed in git-hub server.
We are unable to figure out the reason for not covered by sonar though the new testcase code changes added to the file.
In local machine, eclipse jacoco plugin the new code changes are showing it as covered but in the build server the new code changes are not covered by sonar.

Here is the project server setup details.
SonarQube version: 7.9.1

Jenkins cloudbees

In windows 10 Local machine, eclipse maven project test cases are working but in build server new lines of code is not covered by sonarqube.

please provide us the solution to debug this issue.
Thanks for the help in advance.

Regard’s
RaghuShankar A.C

Hi,

Welcome to the community!

Can you share your analysis logs?

 
HTH,
Ann

1 Like

Hi i am facing the exact same issue, the coverage data is uploaded and displayed except of 2 files.
I assume the cause for me and " RAGHUSHANKAR A C" is the same.

Here are the regarding files, logs, links etc:
File displayed as 0% covered: Sonarcloud - reactj
CI Log (gradle sonarqube) : build(gh): fix sonarqube codecov · nbrugger-tgm/reactj@da68256 · GitHub (note: the failing ci step is not connected to sonar)
“Real” coverage file: jacoco.html (github artifact)

Hi @Niton,

If I’m reading this right, your log shows your coverage step running after your SonarQube analysis. For this to work, it needs to run before analysis so you can feed the resulting log into analysis.

 
HTH,
Ann

1 Like

Thanks for the response, very much appreciated,

As far as i can tell it should be picked up
image

Also in code its defined to run in the correct order:

 - name: "Build"
  run: "./gradlew classes"
- name: "Test"
  run: "./gradlew test"
- name: "Test coverage"
  run: "./gradlew jacocoRootReport jacocoCoverageVerification"
- name: Archive code coverage results
  uses: actions/upload-artifact@v2
  with:
    name: code-coverage-report
    path: build/reports/jacoco/html/
    retention-days: 2
- name: "Sonar Qube"
  if: always()
  env:
    GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
    SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
  run: "./gradlew sonarqube --info"

Also sonar reports that it does pick the file up: (link to log-line)

Sensor VB.NET Properties [vbnet] (done) | time=0ms
Sensor JaCoCo XML Report Importer [jacoco]
Importing 1 report(s). Turn your logs in debug mode in order to see the exhaustive list.
Sensor JaCoCo XML Report Importer [jacoco] (done) | time=8ms
Sensor CSS Rules [javascript]

Also maybe my statements were not very concise, the report is indeed picked up correctly :slight_smile: The Problem is that one file (sonar cloud link from last post : Sonarcloud - reactj) is displayed with 0% while the jacoco report which is uploaded states that it is 95% covered (link to the correct coverage report (from the same build)

Proof of the report being (mostly) correct:
image

Also i do understand if you are now allowed to download a “random” zip from a forum user. Here is an image of said file:


Sonar coverage:

Thank you for helping

Hi,

Sorry, but I’m not sure where to go from here. This post is already tagged to attract more expert attention. Hopefully they’ll be along soon.

 
Ann

1 Like

Thank you for your help and supporting the OOS community with your free plan :slight_smile:

1 Like

Hi again, i just wanted to ask if there is anything i can do to help you with progressing, like giving you missing information or producing new logs etc