为什么某些 Python 文件没有被coverage.py 检查?
我正在使用coverage.py 来测量Python 项目中的测试覆盖率,但某些Python 文件未显示在覆盖率报告中。这些文件的不同之处在于它们没有被任何测试执行(即,如果它们包含在报告中,它们的覆盖率将为 0%)。
未检查这些文件的可能原因有哪些?如果是因为它们在单元测试期间从未加载,是否可以强制coverage.py将这些文件包含在报告中?
I'm using coverage.py to measure test coverage in a Python project, but some Python files are not showing up in the coverage report. One thing that is different about these files is that they were not executed by any tests (i.e., if they were included in the report, their coverage would be 0%).
What are possible reasons why these files were not examined? If it's because they were never loaded during unit testing, is it possible to force coverage.py to include these files in the report?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您的文件在测试会话期间甚至没有加载,它们甚至不会出现在覆盖结果中。但是您可以使用 < 强制coverage.py 测量您想要的每个文件中的“非”覆盖率代码>源选项。它甚至会将未加载的源代码包含到覆盖率报告中。
If your files are even not loaded during your testing session, they won't even appear in coverage result. But you can force coverage.py to measure "non" coverage in every file you want with the
source
option. It will include even non loaded source code to the coverage report.