Python coverage at 0%

I’m having the same problem. I’ve trying to figure out why the python code coverage displayed on the project page stays at 0% whatever I change in the configuration.

I’m working with the docker images of SQ.
The coverage value in Java is shown correctly.
In python it stays at 0 on the server although the local value given by coverage in html, text or xml is correct.
My indoor version of SQ as well as the one on sonarcloud.io have the same problem.
Instead of working with the 7.7 version I moved back to the the version 6.7.7 and, hourra !, the coverage value was correctly displayed.

Hi,

I’ve split this off from the thread you posted in originally because it’s not clear to me that it is the same problem. That thread was about coverage in PRs but you say you got the functionality you wanted when you regressed to 6.7, so I’m guessing we’re talking about the main branch here?

Either way, it would be helpful if you could share your analysis logs.

 
Ann

Actually I faced different problems interacting together:

Contrary to what I read and understood in the documentation settings in the SQ server configuration override values in scanner properties file. My reportPath (or reportPaths) was not correct in SQ but good in the scanner. This prevented the coverage value from being displayed.

And at this point SQ 7.7 does not manage coverage whatever I try (but I may have something wrong somewhere)

What do you see in the logs of the analysis with SQ 7.7?
You should find something about coverage of python files. For example:

INFO: Sensor Cobertura Sensor for Python coverage [python]
INFO: Python test coverage
INFO: Parsing report '/Users/user1/test/python/python-test/coverage.xml'
INFO: Sensor Cobertura Sensor for Python coverage [python] (done) | time=24ms

'm getting crazy. Today no coverage reports shows up even with the 6.7.7 version (dockerized)
And I’m unable to find out the difference between what I did 2 days ago and today.

Although in the scanner log I see :

13:27:29.675 INFO: Sensor Cobertura Sensor for Python coverage [python]
13:27:29.676 DEBUG: Using pattern ‘coverage-reports/coverage-.xml’ to find reports
13:27:29.687 INFO: Python test coverage
13:27:29.689 INFO: Parsing report ‘/home/myself/work/git/jplf/python/lab/coverage-reports/coverage-b.xml’
13:27:29.727 INFO: Sensor Cobertura Sensor for Python coverage [python] (done) | time=52ms

I’v checked my config hundreds of time.

Some ideas of what could go wrong with your coverage report:

  • it’s empty when the SonarQube analysis is run.
  • it only mentions test files.
  • it only mentions files which are excluded with sonar.coverage.exclusions.

We could help if you shared:

  • the configuration of the analysis (sonar-project.properties if you use sonar-scanner)
  • the content of your coverage report
  • the complete logs of the analysis

I’ve just found an explanation:

  • my /home directory is a symbolic link to a directory created in partition named ‘xtra’
    /home/myself/workdir/reports is actually /xtra/home/myself/workdir/reports
    The command coverage generates the coverage.xml file with the actual full path which is not consistent with what sonar-scanner does.
    I manually fixed the name in the xml file and I got the right coverage values.

It took me 3 days to figure that out :frowning:

1 Like

I have the same issue , python coverage shows 0%, what is the solution? I have added the location for sonar.python.coverage.reportPath=/tests/*.xml, as we have test results to separate xml files.

1 Like

I am having this same issue as well. I added the coverage report from pytest to sonar.python.coverage.reportPath

Please open a new thread.