red, green, refactor … commit

Posted on September 29, 2008

3


As time passes I find myself getting more and more nervous about the amount of time between passing tests, and between commits to the source code repository. So when Neil asked me today where I put the “commit” step in my TDD practice, I said:

red
green
   commit
refactor
   commit

That extra “commit” at the green bar captures the safe state, in case I get distracted by the kids or forget to take my medication. It also shares that working code with the rest of the team, which in turn makes sure I get feedback on whether it builds. And that also makes sure those tests get run more frequently and outside of my environment sooner.

Recently I’ve been learning to use Git (which I like a lot, although some of the differences from Subversion stil baffle me a little). Anyroadup, with Git I can get even more safety from the process:

red
   commit
green
   commit
   push
refactor
   commit
   push

The extra “commit” at the red bar is local to my repository. It means I can “stop on a red bar”, as used to be recommended in the early days of TDD, and yet still have all my code checked in.

I wonder whether I’m becoming more paranoid as Old Age now has me in its grip…

Advertisement
Tagged: ,
Posted in: tdd, Uncategorized