站长译:“为什么软件测试如此重要 ” 本文来自 https://hackernoon.com/

翻译 by 葫芦娃 润色&术语校对:站长

It isn't about being diligent. It's because we've forgotten what we knew.

不是为了勤奋。因为我们忘记了我们所知道的。

Bizarro World Software Development

比扎罗(?)世界软件开发

Anyone reading public discussions about software development might not even know that the main objective is the production of executables. One could be forgiven for having the impression that the sole objective of software development is unit testing.Articles about coding practices are few and occasional; articles about testing strategies are legion. And they tend to be either strangely exuberant (a happy team sitting in each others’ laps and writing tests) or scolding (anything other than 100% code coverage is slipshod and undisciplined).It didn’t use to be like this. We used to focus on development, and while we did enough testing of our own work we knew, and knew clearly, that this was just the beginning, that a team of dedicated SDETs would do the real testing, based on a functional specification and unprejudiced by knowledge of the code.

任何有关软件开发的人都可能不知道主要目标是生成可执行文件。人们可以原谅这样的印象:软件开发的唯一目标是单元测试。

关于编码实践的文章很少,而且是偶发的;关于测试策略的文章很多。而且他们往往要么异常活跃(一个快乐的团队坐在彼此的圈里编写测试),要么责骂(除了100%的代码覆盖率之外的任何东西都是草率的和没有纪律的)。

以前不是这样的。我们过去专注于开发,虽然我们对自己的工作做了足够的测试,但我们知道,并且清楚地知道,这只是一个开始,一个专门的sdet团队将根据功能规范进行真正的测试,并且不受代码知识的影响。

Nomenclature

命名法

BlackBox Testing: testing an executable using a functional specification as a guide, without knowledge of the code or the implementation design, based on behaviour and tested in the user interface (EXE) or a test harness (DLL).WhiteBox Testing: same as BlackBox but with knowledge of the code and thereby prejudiced. Generally done by developers and perfunctory, not recommended for conclusive testingUnit Testing: testing code functions directly, passing them sample data sets, usually done by the developer and mistakenly regarded as conclusive, often credited with magical powers and regarded by many as defining entry point documentation. See Test-Driven Development

BlackBox(黑盒)测试:以功能规范为指导,在不了解代码或实现设计的情况下,基于行为测试可执行文件,并在用户界面(EXE)或测试工具(DLL)中进行测试。

白盒测试:与BlackBox相同,但对代码有一定的了解,因此有偏见。一般由开发人员做而敷衍,不建议作结论性测试

单元测试:直接测试代码函数,将样本数据集传递给它们,通常由开发人员完成,并被误认为是决定性的,通常被认为具有神奇的能力,被许多人视为定义入口点文档。参见测试驱动开发

Traditional Testing

传统方法

Traditional software testing is BlackBox. The developer either writes or is given a functional specification, implements it, tests it enough to know that basic functionality is sound and likely edge cases work, then delivers it to BlackBox testers, one or more, who specialize in testing. In ideal cases, a developer and SDET work closely together and do as much as possible to bypass the bug database and triage tedium.Admittedly in past times, many companies did not do enough of this. Since my work often went live on servers within hours of bug discovery, it was important to test thoroughly and I spent half my day in my tester’s office sometimes. We worked together well.But some companies regarded testing as a box to check and nothing more.

传统的软件测试是黑盒测试。开发人员要么编写或获得一个功能规范,要么实现它,对它进行足够的测试,以了解基本功能是健全的,而且可能是边缘案例工作,然后将其交付给专门从事测试的BlackBox测试人员(一个或多个)。在理想情况下,开发人员和SDET紧密合作,尽可能地绕过bug数据库和分类繁琐。

诚然,在过去,许多公司并没有做到这一点。由于我的工作经常在发现错误后的几个小时内在服务器上进行,所以彻底测试是很重要的,有时我会在测试人员的办公室里花半天时间。我们合作得很好。

但一些公司认为测试只是一个检查框,没有更多。

Test-Driven Development

测试驱动开发

Arguing with my manager in 2008 about writing unit tests for my release-ready application, too small to be decomposed into units, the conversation got crazier and crazier and it went into lunacy territory when he mentioned a new thing called “test-driven development.”The first thing that came into my mind was that despite the most diligent planning anyone has ever done, we learn things during development that we hadn’t anticipated in design, so tests written before this would either be incomplete or require constant revisiting, which is a waste of time compared to writing them after implementation is finished. Not catastrophically so, but backwards.But TDD has come to dominate the industry despite this, and now testing has replaced development itself as the core of … software development. I’ve already written about this elsewhere and won’t repeat it here:https://hackernoon.com/software-development-is-not-about-unit-tests-r77132y7but in discussions in reaction to this and other articles, I’ve learned that things are a lot, lot worse than I thought.

2008年,我和我的经理争论为我的可发布应用程序编写单元测试,这个程序太小,无法分解为单元,当他提到一个叫做“测试驱动开发”的新东西时,对话变得越来越疯狂,进入了疯狂的境界

我首先想到的是,尽管有人做过最勤奋的计划,但我们在开发过程中学到了设计中没有预料到的东西,因此在此之前编写的测试要么是不完整的,要么需要不断的重新访问,与在实现完成后编写它们相比,这是浪费时间。不是灾难性的,而是倒退。

但尽管如此,TDD已经在业界占据主导地位,现在测试已经取代了开发本身,成为软件开发的核心。我已经在其他地方写过了,不会在这里重复:

https://hackernoon.com/software-development-is-not-about-unit-tests-r77132y7

但在对这篇文章和其他文章的讨论中,我发现事情比我想象的要糟糕得多。

Why Johnny Can’t Code

为什么约翰尼(?)不能编代码

Long before the personal computer revolution, the few companies developing software had already noticed that some programmers were much more productive than others and produced superior code. It wasn’t any difference in intelligence, it wasn’t faster typing, it wasn’t longer hours. Research showed that the key to this superior performance was the ability to enter periods of prolonged and unbroken concentration, which was called Flow. See the Resources for more on this, or read my other article:https://medium.com/swlh/the-magnificence-of-flow-c5fad8da35a1The reason Microsoft was such a great place to work until it grew so much was that this recognition was woven into their corporate culture; we had private offices and minimal interruptions.It didn’t last. Maximizing shareholder value meant doubling or quadrupling office occupancy, we were called to more and more meetings.The important point here is that being able to concentrate is essential to doing good work.

早在个人电脑革命之前,为数不多的开发软件的公司就已经注意到,一些程序员的工作效率远远高于其他程序员,并产生了优秀的代码。在智力上没什么区别,打字也不快,时间也不长。研究表明,这种优越性能的关键是能够进入长时间和不间断的浓缩期,即所谓的流动期。请参阅参考资料以了解更多信息,或阅读我的其他文章:

https://medium.com/swlh/the-magnificence-of-flow-c5fad8da35a1

微软之所以在发展壮大之前一直是一个很好的工作场所,是因为这种认可融入了他们的企业文化;我们有私人办公室,很少有人打扰。

没有持续多久。股东价值最大化意味着办公室占有率翻倍或增加了四倍,我们被召集到越来越多的会议。

这里重要的一点是,能够集中精力是做好工作的必要条件

Because Johnny Can’t Concentrate

因为不能集中注意力

I like working alone. I like closing the door to my unshared office, turning out the lights, putting on the headphones playing brooding ambient music, focusing in and coding for hours. I can do weeks of work and have everything work with few or no bugs when everything is done. I can concentrate.Concentration has gone out of style in software.The reason you’re so obsessed with testing is because you can’t concentrate, so you can’t write good code.You start your day with an utterly pointless daily scrum (a neologism for a status update; we used to do these in email), scheduled for 8:30 or 9 AM, so your day begins after a mind-numbing slog of a rush-hour commute that leaves you weary from the start.Your day is constantly interrupted by “team” interactions and recurring meetings.You are told to respond promptly to emails so you leave popups enabled and break from work to respond to them.You take frequent breaks for “team” events and online gaming.And worst of all, you’ve never learned to concentrate in the first place. You watch TV and you switch channels every few seconds, you spend hours on social networks where 280 characters strain your attention span, it takes you months to read a novel if you read at all, you play games where response times are instant so you never have to wait for anything longer than microwaving macaroni and even then you dance from foot to foot going “come on, come on.”You never had a chance, you poor sap. So you write tons of tests.

我喜欢一个人工作。我喜欢关上办公室的门,关上灯,戴上耳机播放沉思的环境音乐,专心工作,编码几个小时。我可以做几周的工作,当所有的事情都完成时,我可以让所有的事情都在很少或没有错误的情况下工作。我可以集中精神。

在软件领域,专注已经过时了。

你如此痴迷于测试的原因是你不能集中精力,所以你不能写出好的代码。

你的一天从一个完全没有意义的每日scrum开始(一个状态更新的新词;我们以前在电子邮件中这样做),计划在上午8:30或9点,所以你的一天开始后,一个令人麻木的高峰时间通勤,让你从一开始就疲惫不堪。

你的一天经常被“团队”互动和定期会议打断。

你被告知要及时回复电子邮件,这样你就可以让弹出窗口保持启用状态,下班后再回复它们。

你经常在“团队”活动和在线游戏中休息。

最糟糕的是,你一开始就没学会集中精力。你看电视,每隔几秒钟就换一个频道,你在社交网络上花上几个小时,280个字符会让你的注意力分散,读一本小说要花上几个月的时间如果你真的读到了,你玩的游戏反应时间很快,所以你永远不必等待比微波通心粉更长的时间,甚至你还可以从脚上跳舞“走吧,走吧”

你从来没有机会,你这个可怜的笨蛋。所以你写了很多测试

People Who Concentrate are Toxic

注意力集中的人是很厉害的

I’ve been told this many times now. Seriously.On a freelancing agency blog, a manager (who hastened to brag about his hiring authority) told me that he wouldn’t hire someone like me who worked alone because “individualistic” programmers bring toxicity to the “team” and end up demoted and terminated.On Twitter, a purported developer told me that people who are “obsessed with focus” are mentally unstable and that “people skills” are more important than productivity.Uh, yeah.There is a distinct hostility toward developers who work alone, and what was once the pinnacle of software productivity is now regarded with disdain and suspicion. "Not a team player." Teams are for sports.Well then I proudly cop to not being a team player, to being a lone wolf, and I don’t get to put my feet up on the team table with the others and I don’t get invited to the alcohol-fueled team morale events. Fine with me.But I write solid code, I can handle huge amounts of responsibility, I can manage vast amounts of detail because I can concentrate for a very long time.And I’m never working anywhere they won’t let me do that.Our industry is a mess.

我听说过很多次了。真的。

在一个自由撰稿机构的博客上,一位经理(他急切地吹嘘自己的招聘权限)告诉我,他不会雇佣像我这样独自工作的人,因为“个人主义”程序员给“团队”带来了毒害,最终被降级并终止。

在Twitter上,一位据称是开发人员的人告诉我,那些“痴迷于专注”的人精神不稳定,“人际交往技巧”比生产力更重要。

嗯,是的。

人们对单独工作的开发人员有着明显的敌意,曾经是软件生产力的顶峰,现在却以轻蔑和怀疑的态度看待。不是团队合作。“团队是为了运动。"

但是我写的代码很扎实,我可以承担大量的责任,我可以管理大量的细节,因为我可以集中精力很长一段时间。

我在任何地方工作他们都不让我这样做(?)

我们的行业一团糟。


暮春三月,江南草长,杂花生树,群莺乱飞