Coverage-Gutter extension for visual studio code is not showing line coverage in python3 project
Asked Answered
M

3

6

I installed coverage gutter extension for visual studio code but is not showing the line coverage, when I press Coverage Gutter display coverage or press the "watch" option in the footer it says "Could not find coverage file"

In this github doesn't mention anything about configuring a coverage file or anything

https://github.com/ryanluker/vscode-coverage-gutters

this is a code of one of my test I'm using unittest

class Test_SetValuesService(unittest.TestCase):

def test_given_none_property_when_checking_if_none_return_empty(self):
    #ASSERT
    self.assertEqual("&nbsp", setValuesService.check_if_json_property_is_null(""))

The error that I'm getting is a message that says "Could not find a Coverage file!"

Mullet answered 5/11, 2019 at 16:31 Comment(0)
R
13

By default, Coverage Gutter expectes to read the coverage data from a cov.xml file in the root of your project which contains the coverage data.

E.g. run this in the root folder of the project. It will run all tests within the test/ folder and will create a cov.xml

pytest --cov=. tests/ --cov-report xml:cov.xml

Of course you need to have the correct python plugins installed, which are "pytest", "coverage" and "pytest-cov" in this case.

You can also adjust the default filename which is used in the extension settings of coverage gutter within visual studio to sth. like mypersonalcovfile.xml if you like.

Recha answered 25/2, 2020 at 12:28 Comment(0)
N
0

It looks like Coverage Gutters will read an lcov file or a .xml file. Have you generated a coverage.py xml file? For example, with coverage xml.

Not answered 6/11, 2019 at 12:1 Comment(0)
F
0

Coverage-Gutter extension reads only specific file type

"coverage-gutters.coverageFileNames": [
        "lcov.info",
        "cov.xml",
        "coverage.xml",
        "jacoco.xml",
        "coverage.cobertura.xml"
    ]

So you would have to convert your coverage file to these file types to make it work.

If you have a .coverage file (which I had come across while working on a python module), you can convert it to a lcov.info file by using the pip-package coverage-lcov.

Tho, in my case I had to manually input the file path in vs-code settings as well

"coverage-gutters.manualCoverageFilePaths": [
    "/path/to/your/dir/lcov.info"
],
Flask answered 8/8 at 16:15 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.