如何说服团队中的程序员进行 TDD? [英] How do I convince programmers in my team to do TDD?

查看:39
本文介绍了如何说服团队中的程序员进行 TDD?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道这个问题:https://stackoverflow.com/questions/428691/how-to-encourage-implementation-of-tdd

在我的团队中,我们编写了很多单元测试.但是,通常程序员倾向于在编写代码后编写单元测试.所以,我们首先完成模块功能,然后编写测试.对于大多数模块,我们的覆盖率约为 70%.我曾尝试说服我的技术经理和我的团队成员进行纯 TDD,其中我们首先编写测试,然后编写代码,但徒劳无功.我认为首先编写测试可以让我们更好地发现设计.我是不是太挑剔了,尤其是当我们的覆盖率很高时?如果这个问题的答案是否定的,那么我如何与人们交谈以采用测试优先的方法.

In my team, we write a lot of unit tests. But, in general the programmers tend to write unit tests after wrting the code. So, we first finish the module functionality and then write tests. Our coverage is around 70% for most modules. I have tried convincing my technical manager and my team members to do pure TDD wherein we first write tests and then the code, but invain. I think writing tests first allows us to discover design better. Am I just being finicky, especially when our coverage is quite high? If the answer to this question is no, then how do I talk to people to have a test-first approach.

我认为在编写代码后编写测试更容易.我团队中的人已经习惯了这样做,并且反对任何改变.

I think writing tests after writing code is an easier thing to do. People in my team have got accustomed to do this and are opposing any change.

推荐答案

我不知道您可以告诉很多人让他们相信 TDD 的价值.您可以引用专家告诉我们的内容以及您自己的个人经历,但如果人们不愿意尝试,那么您与他们分享这些信息会有所帮助的可能性很小.

I don't know that there is a whole lot you can tell people to convince them of the value of TDD. You can cite what the experts have told us about it, and your own personal experiences, but if folks are not willing to give it a try, chances are low that you sharing this information with them will help.

我对 TDD 的经验基本上是,它听起来是一个非常好的主意,但它从未真正按照预期的方式实现.然后有一天,我在一项新任务上再次尝试,最终得到了一个比我想象的更简单的问题解决方案,这完全是因为我使用了 TDD.我认为,当开发人员拥有这种经验时,他们看待事物的方式会发生变化,并且使他们更愿意在其他情况下进行尝试.

My experience with TDD was basically that it sounded like a really good idea, but it never really worked out the way it was supposed to. Then one day I tried it again on a new task and ended up with a solution to the problem that was simpler than what I would have thought possible, due entirely to the fact that I had used TDD. I think when developers have this sort of experience it changes the way they look at things, and makes them more willing to try it in other situations.

挑战在于能够向其他开发者展示这一点.您可能能够做到这一点的一种方法是使用像 this one 这样的 TDD Kata来自 Roy Osherove(他在他的 TDD 硕士课程中使用了它).它专门设计用于展示小步骤工作的价值,仅实现使每个测试通过所需的代码.这可能会向人们展示该过程是如何工作的,并使他们更愿意尝试一下.

The challenge is being able to demonstrate this to the other developers. One way you may be able to do this is with the use of a TDD Kata like this one from Roy Osherove (he uses it in his TDD Master Course). It is designed specifically to demonstrate the value in working in small steps, implementing only the code that is needed to make each test pass. This may show folks how the process works, and make them more comfortable with giving it a try.

我听说还有一个编码练习,你给两组/开发人员一个相当简单的任务,并要求其中一个组使用 TDD,并确保他们遵循可能工作的最简单的事情"规则,而其他团队则随心所欲地做事.然后,一旦完成,您让团队切换任务,但丢弃每个团队编写的代码,只留下测试.然后团队应该重新创建任务的代码.通常,您会发现继承 TDD 代码的团队更容易做到这一点.

There was also a coding exercise I heard about where you gave two groups/teams of developers a reasonably simple task, and asked one of the groups to use TDD, and make sure they followed the "simplest thing that could possibly work" rules, while the other team did things however they wanted. Then, once that is done, you have the teams switch tasks, but throw out the code written by each team, leaving only the tests. The teams are then supposed to recreate the code for the task. Typically you will find that the team who inherits the TDD code has a much easier time doing this.

尽管如此,我认为个人能做的最好的事情就是开始为尽可能多的工作自己做 TDD.这有可能为您提供一些非常具体的参考,说明 TDD 在当前项目的上下文中在哪里以及如何证明是有益的.特别是如果您进行代码审查,您的同行可能会注意到您编写的 TDD 代码比没有使用 TDD 编写的代码更简洁、更易于维护.您的 QA 团队也可能会注意到代码质量的差异,这是您经常听到关于转向 TDD 的公司的事情之一.

Given all that, though, I think the best thing you can do personally is to start doing TDD yourself for as much of your work as possible. This has the potential to give you some very specific references for where and how TDD has proved to be beneficial within the context of the current project. In particular if you do code reviews your peers may notice the code that you are writing TDD is more concise, and easier to maintain than the code that has been writing without TDD. Your QA team may also notice a difference in the quality of the code, which is one of the things that you hear a lot about companies who move to TDD.

这篇关于如何说服团队中的程序员进行 TDD?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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