0

I'm working on creating unitest for a django project

I installed sonarqube:

docker run -d --name sonarqube -e SONAR_ES_BOOTSTRAP_CHECKS_DISABLE=true -p 9000:9000 sonarqube:latest

through docker image and sonar-scanner using this command:

docker run -v /home/hind/Desktop/map-manager:/usr/src --network="host" sonarsource/sonar-scanner-cli -Dsonar.host.url=http://localhost:9000/ -Dsonar.login=sqp_e7171bd635104a04d29c523243cf54000946ea7f

and I before that I added coverage to my project , I created 23 unitest and all running well except for one that is failling

I run tests with:

coverage run manage.py run test maps  

and when I run the report of the

sonarqube resultcoverage report 

and the report is displaying this:

Name                            Stmts   Miss  Cover
---------------------------------------------------
app/__init__.py                     0      0   100%
app/settings.py                    58     10    83%
app/urls.py                        12      0   100%
manage.py                          13      6    54%
maps/__init__.py                    0      0   100%
maps/admin.py                     141     62    56%
maps/migrations/__init__.py         0      0   100%
maps/models.py                    163     10    94%
maps/templatetags/__init__.py       0      0   100%
maps/tests.py                     195      3    98%
---------------------------------------------------
TOTAL                             582     91    84%

but in sonar-scanner I get 0.0% coverage and nothing in unittest:

Sonarqube results

I'd like help figuring out how to get the coverage analyzed and reported as non-zero, like in the command line based results shown above.

joanis
  • 10,635
  • 14
  • 30
  • 40
H_E
  • 1
  • Can you share your build process configuration? Based on https://docs.sonarqube.org/9.7/analyzing-source-code/test-coverage/python-test-coverage/ you have to add coverage in your build configuration, so we'd need to see your config to help. – joanis Jun 08 '23 at 01:14

1 Answers1

0

Did you set sonar.python.coverage.reportPaths with the path to your Cobertura-formatted XML file? Is it in your sonar-project.properties file? I don't see you setting it at the command line when you run your Sonar scanner. See https://docs.sonarqube.org/latest/analyzing-source-code/test-coverage/test-coverage-parameters/#python.

sonar.python.coverage.reportPaths

Comma-delimited list of paths to coverage reports in the Cobertura XML format. Wildcards are supported. Leave unset to use the default, coverage-reports/coverage-.xml.

Please enable DEBUG Sonar scanner logs sonar.verbose=true and check your logs for the phrase Sensor Cobertura Sensor for Python coverage.

For more information, see https://docs.sonarqube.org/latest/analyzing-source-code/test-coverage/python-test-coverage/.

In the future, you should post on https://community.sonarsource.com/, which is where the Sonar devs can respond to you directly.