Import python coverage report to sonarqube Dasboard

Hello All,

   how can import coverage report to sonarqube dashboard.

Hello @AbobakrAhmed,

Welcome to the SonarSource community. :wave:. I hope you will enjoy it.
It quite important when you open a thread to elaborate on what you tried already. Your post is a bit too blunt for us to help you. Did you at least read and try to implement what’s documented at https://docs.sonarqube.org/latest/analysis/coverage/ (check Python there)

Olivier

Hello @OlivierK ,

  sure already did that by add ![Jenkinsfile|504x33](upload://c2rCqtSj0sgktVStsOdRDAoerOP.png)  

NOTE: using jenkins for automate testing with sonarqube

I assume that you already read the docs. Great.
Now, can you share with me something else than a terminal screenshot ?
For instance:

  • The logs of your jenkins pipeline
  • What you get in SonarQube (screenshot of the project home page)
  • What you would expect to get and you don’t (0% coverage, non zero but incorrect coverage ? …)

Olivier

i have server for testing application and another for jenkins and another for sonarqube , when testing from jenkins showing this error

that’s my pipeline

Please send me logs (and anything else you can like your pipeline) in text format, not screenshots. I cannot investigate.
One thing that you may want to double check before getting back to me. Do you generate coverage (that coverage.xml file) before running SonarQube ?
SonarQube does not produce the coverage out of the blue. You have to write tests that you run to generate coverage and then SonarQube imports this coverage.
Please read: https://coverage.readthedocs.io/en/coverage-5.3/ and https://docs.sonarqube.org/latest/analysis/coverage/#header-1, confirm that you do that when you come back to me and show me evidence of it (I can’t see any evidence of you running coverage tests in what you sent me so far)

Olivier

Hello @OlivierK

   Very sorry for being late reply , kindly check the attachment file  [Pipeline-logs.txt|attachment](upload://7cVddGdGbju0cJKrU5fn1aEl2JX.txt) (3.8 KB) , this from jenkins server don't have coverage tool just received coverage file from testing server and try to send for sonarqube

Nothing is attached @AbobakrAhmed :sob:. There must have been a glitch with your post :wink:

coverage.txt (138.3 KB)

Hello,
The attached filename is misleading but this not the coverage file.
This is your pipeline console log file.
The good thing is that the pipeline log gives me the full path of the coverage file, it’s /home/ec2-user/accept/paymob_accept/workspace/AcceptStaging-Ecommerce-Pipeline/coverage.xml

The likely problem is that this coverage file is not generated as part of the pipeline (it’s apparently generated beforehand). It’s a bad practice, because it’s likely to be a coverage file that does not exactly corresponds to the source files analyzed.
You must run the tests / coverage tool as part of the pipeline, and make sure it generates a report in Cobertura XML format. See https://pytest-cov.readthedocs.io/en/latest/reporting.html

Olivier

Hello @OlivierK

Thank you it’s working now

Great. Enjoy SonarQube!

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