Code coverage of a file is not shown eventhough it's unit test is written

I am using the latest SonarQube Enterprise Version.

I have a python file named project/projectName/script/fileName.py. This file has many methods written.

Also, I have the unit test written for the fileName.py under the location project/projectName/test/fileNameTest.py.

In SonarQube I am not able to see the percentage of the coverage of fileName.py. It is shown as 0.0% even though I have written the test classes of the methods in the file fileNameTest.py.

But SonarQube calculates the entire project’s code coverage successfully in the Overview section of the dashboard.

Why the coverage percentage of some specific files are not calculated/not displayed even though it’s unit test for methods are written.?

Hey there.

SonarQube relies completely on the coverage report to determine if a file has coverage (it doesn’t estimate this itself). (Docs: Python test coverage)

So I would suggest looking directly at the report being passed to SonarQube to see if coverage has been correctly reported. If yes – there’s a problem with how SonarQube is reading the data! But if not (and this is usually the case), then you have the problem at the source and make sure the coverage report has the data you expect.