How to instill the TDD habit in a team [duplicate]
Possible Duplicate:
How do I convince programmers in my team to do TDD?
What are some of the best ways to encourage and instil the TDD habit into a team that has never used TDD?
Can anyone share their experiences with the right and wrong way to get a team using TDD such that they find it effective and want to keep using it on all future projects?
This may be simply getting you out of the frying pan and into the fire, but we've found that the best way to really convince people to adopt TDD is pair programming. TDD is one of those things that most people will intellectually know is effective, but they won't consistently apply it until they feel the benefit in their gut. Convincing a person's gut usually involves having someone sit with them and really do TDD for a time -- for some people this is a few days, for some a few weeks -- until they have that aha! moment when TDD saves them hours of debugging.
If people don't want to do it you'll have a hard job convincing them of the benefits. If they are just unaware of it or agnostic, I'd recommend discussing it with them (maybe a presentation? team meeting?) and then offering to pair with them to fix a few bugs in that fashion - hopefully, they'll learn the benefits through experience.
In the first instance you need to ensure the devs get training in how to effectively do test-driven development. After having mastered xUnit they should get training in how to employ mock objects. This is a more sophisticated kind of tdd (from 'development' to 'design', really), and one that appeals to aspiring developers, because by employing the technique they should produce better code, in addition to being able to better test interactions.
I mention the above advantages because it's one way I try to convince teams to adopt TDD.
However, the true answer to this question is to set up Continuous Integration, with the option to reject code that does not have accompanying unit tests :-)
Good luck
精彩评论