7

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.

1

1 Answer 1

3

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.