We have a junior programmer that simply doesn’t write enough tests.
I have to nag him every two hours, ‘have you written tests?’
We’ve tried:
- Showing that the design becomes simpler
- Showing it prevents defects
- Making it an ego thing saying only bad programmers don’t
- This weekend 2 team members had to come to work because his code had a NULL reference and he didn’t test it
My work requires top quality stable code, and usually everyone ‘gets it’ and there’s no need to push tests through. We know we can make him write tests, but we all know the useful tests are those written when you’re into it.
Do you know of more motivations?
This is one of the hardest things to do. Getting your people to get it.
Sometimes one of the best ways to help junior level programmers ‘get it’ and learn the right techniques from the seniors is to do a bit of pair programming.
Try this: on an upcoming project, pair the junior guy up with yourself or another senior programmer. They should work together, taking turns ‘driving’ (being the one typing at they keyboard) and ‘coaching’ (looking over the shoulder of the driver and pointing out suggestions, mistakes, etc as they go). It may seem like a waste of resources, but you will find:
Maybe also have someone in your group give the Unit Testing 101 presentation by Kate Rhodes, I think its a great way to get people excited about testing, if delivered well.
Another thing you can do is have your Jr. Devs practice the Bowling Game Kata which will help them learn Test Driven Development. It is in java, but could easily be adapted to any language.