您如何围绕向构建添加单元测试来定制开发流程?

发布于 2024-09-25 01:06:33 字数 1431 浏览 7 评论 0原文

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

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

发布评论

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

评论(3

故事和酒 2024-10-02 01:06:33

无论如何,我很好奇阅读什么
对这个过程有什么想法?请
保持简短。你的团队有吗
包括构建中的单元测试。如果
那么,你遵循 TDD 吗?你总是
努力让你的构建保持测试
一切都过去了?

好吧,我们并不总是完全一致,但原则上:是的,是的。

第 1 点:

恕我直言,您确实必须在日常构建中运行测试。否则,在您没有预料到的地方的测试失败将在一段时间内被忽视——这违背了单元测试的全部目的。仅当立即发现测试失败时,它才有用。

显然,在开发过程中会有破坏测试的阶段(例如重构)。但这些应该尽可能短(理想情况下是几分钟),并且您通常只在它们通过后才签入(就像您只在东西编译后签入一样)。如果您需要进行更广泛的返工,您需要一个私有分支:-)。

第 2 点:

至于测试失败时会发生什么:好吧,你修复它们(你,或者任何破坏它们的人)。在一个好的团队中,严厉的斥责是不必要的。但这确实是一个社会问题......

Anyway, I'm curious to read what the
thoughts are on this process? Please
keep them brief. Does your team
includes units tests in the build. If
so, do you follow TDD? Do you always
strive to keep your builds with tests
as all passing?

Well, we're not always perfectly consisten about it, but in principle: yes, and yes.

Point 1:

IMHO, you really must run your tests in the daily build. Otherwise test failures in places where you didn't expect them will go unnoticed for a while - this defeats the whole purpose of unit testing. It's only useful if test failures are noticed immediately.

Obviously, during development there will be phases where you break tests (e.g. refactoring). But these should be as short as possible (minutes, ideally), and you typically only check in once they pass (just as you only check in once stuff compiles). If you need to do more extensive rework, you need a private branch :-).

Point 2:

As to what happens when tests break: Well, you fix them (you, or whoever broke them). Strict reprimands should be unnecessary in a good team. But that is really a social question...

书信已泛黄 2024-10-02 01:06:33

build 应该运行测试,总是通过,对于 TDD

也是如此,如果您有自动化功能测试,也应该运行。通过功能测试,您可能不会让所有测试都通过,但是您永远不应该开始让正在通过的测试失败。

(即......你可以进行一堆功能测试,以证明当前正在处理的事情正在做正确的事情,但在完成之前它不会通过。)

build should run the tests, always passing, and yes for TDD

also, if you have automated functional testing, that should be run also. With functional testing you may not have all the tests passing, however you should never start failing a test that was passing.

(ie.... you can have a bunch of functional tests that will demonstrate that current stuff being worked on is doing the right thing, but until its completed it won't pass. )

放肆 2024-10-02 01:06:33

无论您是否使用 TDD,都不要签入,除非/直到它通过测试。或者,如果您喜欢/必须,您可以将损坏的代码/测试签入未断言测试的“私有”分支。

Whether or not you use TDD, don't checkin unless/until it passes its tests. Or if you like/must, you can checkin broken code/tests to a 'private' branch whose testing isn't asserted.

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