如何确保我的大型 Python 项目具有良好的测试覆盖率

发布于 2024-09-06 20:07:00 字数 406 浏览 5 评论 0原文

我有一个非常大的 python 项目,有一个非常大的测试套件。最近,我们决定量化我们的测试覆盖率的质量。

我正在寻找一种工具来自动生成测试覆盖率报告。理想情况下,我希望有有吸引力的、易于阅读的报告,但如果我能让它快速工作,我会接受不太有吸引力的报告。

我尝试过Nose,但它不够好:它与distribute / setuptools的命名空间包功能不兼容。不幸的是,鼻子覆盖永远不会对我们有用,因为我们充分利用了这个功能。这真是太遗憾了,因为 Nose 似乎在 Hudson 中工作得很好(大部分)。

作为替代方案,我听说有一种方法可以在 Eclipse 中进行 Python 覆盖率分析,但我还没有完全锁定完美的技术。

欢迎任何建议!

仅供参考,我们在 Windows XP 32 位上使用 Python 2.4.4

I have a very large python project with a very large test suite. Recently we have decided to quantify the quality of our test-coverage.

I'm looking for a tool to automate the test coverage report generation. Ideally I'd like to have attractive, easy to read reports but I'd settle for less attractive reports if I could make it work quickly.

I've tried Nose, which is not good enough: It is incompatible with distribute / setuptools' namespace package feature. Unfortunately nose coverage will never work for us since we make abundant use of this feature. That's a real shame because Nose seems to work really nicely in Hudson (mostly)

As an alternative, I've heard that there's a way to do a Python coverage analysis in Eclipse, but I've not quite locked-down the perfect technique.

Any suggestions welcome!

FYI we use Python 2.4.4 on Windows XP 32bit

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

对你而言 2024-09-13 20:07:00

您是否尝试过使用coverage.py?它是“鼻子覆盖”的基础,但如果需要,可以在鼻子之外完美运行。

如果您使用(假设的)python run_my_tests.py 运行测试,那么您可以使用 coverage run run_my_tests.py 测量覆盖率,然后使用 coverage html 获取 HTML 报告

从你的描述来看,我不确定你的鼻子有什么问题,尤其是鼻子问题,还是coverage.py问题。请提供更多细节,我相信我们可以解决这些问题。

Have you tried using coverage.py? It underlies "nose coverage", but can be run perfectly well outside of nose if you need to.

If you run your tests with (hypothetically) python run_my_tests.py, then you can measure coverage with coverage run run_my_tests.py, then get HTML reports with coverage html.

From your description, I'm not sure what problem you had with nose, especially whether it was a nose issue, or a coverage.py issue. Provide some more details, and I'm sure we can work through them.

谁许谁一生繁华 2024-09-13 20:07:00

Ned 已经提到了他出色的coverage.py 模块。

如果您遇到的问题是鼻子特定的问题,您可能需要考虑使用另一个测试运行程序。我使用了 py.test 以及 pytest_coverage 插件,可让您生成覆盖率统计信息。它还具有 pytest_nose 插件来帮助您迁移。

但是,我不明白您所面临的问题是什么。您能详细说明一下您提到的“distribute/setuptools 的命名空间包功能”吗?我很想知道问题是什么。

Ned has already mentioned his excellent coverage.py module.

If the problem you're having is something nose specific, you might want to consider using another test runner. I've used py.test along with the pytest_coverage plugin that lets you generate coverage statistics. It also has a pytest_nose plugin to help you migrate.

However, I don't understand exactly what the problem you're facing is. Can you elaborate a little on the "distribute / setuptools' namespace package feature" you mentioned? I'm curious to know what the problem is.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文