多少单元测试是一件好事吗? [英] How much unit testing is a good thing?

查看:149
本文介绍了多少单元测试是一件好事吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

(没有相关问题似乎钉这一点,所以在这里不用。)

(No "related questions" seem to nail this, so here goes.)

我对生产code工作。主张任何用户很难做到,有时不可见。如果销售不能看到它,这是一个外部成本给他们,他们会反对它,除非有很大的理由不这么做。

I work on production code. Arguing for anything that isn't visible to the user is hard to do, sometimes. If sales can't see it, it's an external cost to them, and they'll argue against it unless there's a great reason not to.

多少单元测试是一件好事吗?如果测试每个类,每一个方法,你的当前版本需要更长的时间,可能要长得多。如果你没有进行测试,维护在未来将需要更长的时间,可能要长得多的bug修正和新功能的原因问题,你没有预见到,并且该单元测试将会抓住了。

How much unit testing is a good thing? If you test every class, every method, your current release will take longer, possibly much longer. If you test nothing, maintenance in the future will take you longer, possibly much longer as bugfixes and new functionality cause problems you didn't foresee, and that the unit tests would have caught.

你如何找到一个健康,合理的平衡?

How do you find a healthy, justifiable balance?

编辑:回答几个问题,人们合理纷纷上调...

to answer a few questions that people reasonable have raised...


  1. 销售未在运行的过程中,但他们肯定有投入,而的有在任何一组有限的输入。他们是谁支付账单的人。如果他们完全转向了一切,那将是不合理的,很明显。

  1. Sales isn't running the process, but they certainly have input, and should have limited input in any group. They're the ones who pay the bills. If they're completely steering everything, that would be unreasonable, obviously.

我敢肯定没有最好的答案,但我很好奇,其他人的想法是什么是合理的。我期待两个极端(一切!没有!),以及大量的中间。

I'm certain there's no best answer, but I'm curious as to what other people think is reasonable. I'm expecting both extremes (everything! nothing!), and a lot in the middle.

没有人会选择他们的经理,如果在单元测试一个糟糕的政策是与公司/项目的人住一个成功或休息的决定......你有一个的很多更多的职业选择比我们大多数的,朋友。 :-)

No one gets to choose their manager, and if a bad policy on unit testing is a make-or-break decision in someone staying with a company/project... you have a lot more career options than most of us, friend. :-)

第二个编辑:正当是一个重要的词在那里。如果我想有时间的预算/允许进行单元测试,不希望有瞒天过海,我将需要证明的原因。顶部的答案,现在,对我来说,就是考试的事情,之前已经破裂,因为我总能自圆其说的反应策略。

Second "Justifiable" is an important word in there. If I want to have time budgeted/allowed for unit testing, and don't want to have to sneak it in, I'm going to need to justify the why. The top answer right now, for me, is "test things that have broken before", because I can always justify reactive policies.

如何辩解什么积极的任何想法?

推荐答案

为最小的单元测试的两个建议,将提供最为划算:

Two suggestions for minimal unit testing that will provide the most "bang for the buck":

通过分析你的应用程序,找到最常用的部位开始 - 确保这些单位被测试。不断向外移动到不常用的code。

Start by profiling your application to find the most commonly used parts - make sure those are unit tested. Keep moving outward to the less commonly used code.

当一个bug是固定的,写会检测到一个单元测试。

When a bug is fixed, write a unit test that would have detected it.

这篇关于多少单元测试是一件好事吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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