更聪明地编写测试,而不是更难
In my career, I’ve seen many times how teams started with automated testing. Not all attempts were successful. In this post, I’m going to share a few tips on creating a culture of automated testing in your team, and shaping the journey from zero-tests to a reliable set of tests at different levels.
在我的职业生涯中,我曾多次看到团队如何从自动化测试开始。并非所有的尝试都是成功的。在这篇文章中,我将分享一些关于在你的团队中创建自动化测试文化的提示,并塑造从零测试到不同级别的可靠测试集的旅程。
A common way in which some teams approach automated testing is that they set up a target, something like: “In this quarter, we will increase test coverage to X percent”.
一些团队对待自动化测试的常见方式是,他们设定一个目标,类似于。"在这个季度,我们将把测试覆盖率提高到X%"。
I think this is a suboptimal way to achieve higher quality. The ultimate goal is not about having a percentage of lines covered with tests. The goal is to have a fast feedback loop for new changes made to the code, for the whole lifespan of that code base.
我认为这是实现高质量的次优方法。最终的目标不是让测试覆盖一定比例的行。我们的目标是在代码库的整个生命周期内,对代码的新变化有一个快速的反馈回路。
I’ll repeat this, since I’ll be referring to this throughout the post:
我将重复这一点,因为我将在整个文章中提到这一点。
“The goal is to have a fast feedback loop to validate new changes made to the code, for the whole lifespan of the code base”
"我们的目标是有一个快速的反馈回路,以验证对代码所做的新的修改,在代码库的整个生命周期内"
Let’s break this down with an analogy. The goal shouldn’t be to exercise in this quarter for the next beach season, the goal should be to stay in good shape for the rest of one’s life. It’s not about vigorously brushing your teeth for one day once a month, it’s about having a consistent practice of mouth hygiene.
让我们用一个比喻来分解这个问题。目标不应该是在这个季度为下一个海滩季节进行锻炼,目标应该是在一个人的余生中保持良好的状态。这不是说每个月大力刷一次牙,而是要有一个持续的口腔卫生实践。
Similarly, I see automated testing as a set of habits the team follows. And an important aspect of sustaining new habits is to identify the benefits of the new behaviour sooner.
同样,我认为自动化测试是团队遵循的一套习惯。而维持新习惯的一个重要方面是更早地发现新行为的好处。
For the rest of the article, I’ll share my learnings on how to develop these habits faster.
在文章的其余部分,我将分享我对如何更快地培养这些习惯的心得。
The very first thing you should do is…
你应该做的第一件事是...
Understand the expected...