参考博客:https://www.cnblogs.com/coderzh/archive/2009/12/01/pythoncoverage.html

 

1.首先是安装 coverage

1 pip install coverage

 

2.执行如下命令,会执行 yourPyFile文件,并生成  .coverage 文件

1 coverage run yourPyFile.py

python 代码覆盖率 coverage的使用

 

 

3.查看报告

1 coverage report

python 代码覆盖率 coverage的使用

 

 

4.生成 html文件,执行后如图:

1 coverage html -d covhtml

python 代码覆盖率 coverage的使用

 

 

5.打开 5中的 index.htm,如图:

python 代码覆盖率 coverage的使用

 

 可以点对应的 run、missing 将高亮显示相应的代码

python 代码覆盖率 coverage的使用

 

相关文章:

  • 2021-09-23
  • 2021-12-21
  • 2021-07-19
  • 2022-12-23
  • 2021-12-21
  • 2021-11-28
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-06-18
  • 2022-12-23
  • 2022-01-30
  • 2021-11-29
  • 2022-12-23
相关资源
相似解决方案