简体   繁体   中英

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

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!"

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.

Eg 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.

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 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM