Some programmers simply refuse to test. This baffles me but it’s true. Here are some of their excuses:
- It’s too hard
- I don’t know how
- I have to get this done now
- The code I am writing is simple
- It takes too long
I hear at least one of these excuses per week on my current project. Unfortunately we are not pair-programming, so individual programmers must be self-motivated to write tests. There are only a handful of programmers (less than 3 out of about 30) that actually write tests. I believe pair programming bridges the gap between the testers and non-testers, forcing non-testers to become testing ninjas.
I agree that testing is hard and often takes longer to complete a feature. The benefit of having a complete test suite outweighs the alternative, which is not to write tests at all.
Here are a few ways I try to motivate programmers to write tests (with some success):
- When they ask for help, I ask them to explain it with a test
- Sit down with them (temporarily pair up) to implement the feature test-first
- Constantly praise (to programmers and management) how writing tests makes programming easier and more fun

