CI中运行单元测试的最佳最长时间的最佳做法 [英] Best practices for the best max length of time for running unit tests in CI

查看:609
本文介绍了CI中运行单元测试的最佳最长时间的最佳做法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在与TeamCity持续集成在我们公司,我们在每次提交时都进行单元测试(1分钟窗口)。

We are doing continuous integration at our company with TeamCity and we have unit tests running at every commit (1 min window).

最近,我们正在讨论如何长一批单元测试应该持续,但是最短的越好。

Lately, we are debating on how long a batch of unit tests should last but the shortest the better.

但是,我想知道什么是一个单元测试的长度的最佳实践

However, I would like to know what is the best practice for the length of a batch of unit tests?

推荐答案

您可以在单元测试中构建优先级,并且只使用一个子集作为检入门,或 BVT )。不太频繁地运行低优先级测试(例如,每日生成,每个测试通过或每个产品版本)。然后对满足您的开发团队的每个(或每个套件)单独设置执行时间限制。

You could build priorities into your unit tests, and only use a subset as a check-in gate (Build Verification Test, or BVT). Run lower priority tests less often (e.g. per daily build, per test pass, or per product release). Then place separate execution time limits on each (or each suite) that satisfies your dev team.

我的优先级基于我们修复错误的速度测试失败。 P0表示必须修复,即使我们必须缩短时间表,P3表示可能永远不会修复。

I base priorities on how fast we'd jump on fixing the bug signaled by a test failure. P0 means "must-fix, even if we have to slip the schedule", P3 means "may never fix".

我工作的一个团队说不再每个功能的BVTs 2分钟,并没有放置时间限制较低优先级的测试。开发人员必须运行约5个测试套件,我们的签入量排队10分钟的好友是合理的。但是我们的单元测试是大型的,特殊环境需要的集成测试,所以YMMV。

One of the teams I worked on said no more than 2 minutes per feature for BVTs, and placed no time restriction on lower priority tests. The devs had to run about 5 test suites, and it was reasonable with our volume of check-ins to queue up 10 minute buddy builds. But our "unit tests" were big-huge, special-environment-required integration tests, so YMMV.

这篇关于CI中运行单元测试的最佳最长时间的最佳做法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆