[英]Coverage-Gutter extension for visual studio code is not showing line coverage in python3 project
我为 Visual Studio 代码安装了 Coverage Gutter 扩展,但没有显示线路覆盖,当我按下 Coverage Gutter 显示覆盖或按下页脚中的“watch”选项时,它显示“找不到覆盖文件”
在这个 github 没有提到任何关于配置覆盖文件或任何东西
https://github.com/ryanluker/vscode-coverage-gutters
这是我正在使用的一项测试的代码 unittest
class Test_SetValuesService(unittest.TestCase):
def test_given_none_property_when_checking_if_none_return_empty(self):
#ASSERT
self.assertEqual(" ", setValuesService.check_if_json_property_is_null(""))
我收到的错误是一条消息,上面写着“找不到覆盖文件!”
默认情况下,Coverage Gutter 期望从项目根目录中包含覆盖数据的cov.xml文件中读取覆盖数据。
例如,在项目的根文件夹中运行它。 它将运行 test/ 文件夹中的所有测试,并创建一个 cov.xml
pytest --cov=. tests/ --cov-report xml:cov.xml
当然,您需要安装正确的 python 插件,在这种情况下是“pytest”、“coverage”和“pytest-cov”。
您还可以将 Visual Studio 中覆盖范围的扩展设置中使用的默认文件名调整为 sth。 喜欢 mypersonalcovfile.xml 如果你喜欢。
看起来 Coverage Gutters 将读取 lcov 文件或 a.xml 文件。 您是否生成了coverage.py xml 文件? 例如, coverage xml
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.