Python 中的分布式单元测试和代码覆盖率

发布于 2024-12-28 00:07:09 字数 316 浏览 2 评论 0原文

我当前的项目的单元测试代码覆盖率为 100%。我们的持续集成服务不允许开发人员推送没有 100% 覆盖率的代码。

随着项目的发展,运行完整测试套件的时间也随之增加。虽然开发人员通常会运行与他们正在更改的代码相关的测试子集,但他们通常会在提交到 CI 之前进行一次最终的完整运行,并且 CI 服务器本身也运行完整的测试套件。

单元测试本质上是高度可并行的,因为它们在测试之间是独立的且无状态的。它们仅返回两条信息:通过/失败和所覆盖的代码行。映射/归约解决方案似乎效果很好。

是否有任何 Python 测试框架可以在具有代码覆盖率的机器集群上运行测试,并在完成后合并结果?

My current project has a policy of 100% code coverage from its unit tests. Our continuous integration service will not allow developers to push code without 100% coverage.

As the project has grown, so has the time to run the full test suite. While developers typically run a subset of tests relevant to the code they are changing, they will usually do one final full run before submitting to CI, and the CI server itself also runs the full test suite.

Unit tests by their nature are highly parallelizable, as they are self-contained and stateless from test to test. They return only two pieces of information: pass/fail and the lines of code covered. A map/reduce solution seems like it would work very well.

Are there any Python testing frameworks that will run tests across a cluster of machines with code coverage and combine the results when finished?

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

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

发布评论

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

评论(3

秉烛思 2025-01-04 00:07:09

我不知道有任何测试框架可以运行分布在一组机器上的测试,但是鼻子支持使用 多处理

至少这可能是开始创建分布式测试框架的好地方

I don't know of any testing frameworks that will run tests distributed off a group of machines, but nose has support for parallelizing tests on the same machine using multiprocessing.

At minimum that might be a good place to start to create a distributed testing framework

︶ ̄淡然 2025-01-04 00:07:09

我认为没有一个框架能够完全满足您的需求。

我知道 py.test 有 xdist 插件,它添加了分布式测试执行器。您可以使用它在其上编写 CI 基础架构。

I think there is no framework that matches exactly to your needs.

I know py.test has xdist plugin which adds distributed test executors. You can use it to write your CI infrastructure on top of it.

紫轩蝶泪 2025-01-04 00:07:09

不完全是您所看到的,但我能记得的最接近的是 Hadoop 小组使用 JUnit 进行 Hadoop 测试。这是邮件。正如邮件中提到的,搜索 gridunit 论文。

以分布式方式使用 Hadoop 进行单元测试非常有趣。任何围绕此的框架都会非常有用,但开发一个框架应该不会很困难。如果有兴趣请告诉我。

Not exactly what you are looking at, but the closest I could recall is from the Hadoop groups is using JUnit for testing with Hadoop. Here is the mail. As mentioned in the mail search for gridunit papers.

Unit testing with Hadoop in a distributed way is very interesting. Any frameworks around this would be very useful, but developing a framework shouldn't be very difficult. If interested let me know.

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