Test && Commit || Revert (TCR) – Skipping the ‘Red’ Phase

tddtestingunit testingversion control

If you haven't heard of Kent Beck's TCR, it can be summarized with this: any time your tests go green, you commit; anytime your tests go red, you git reset --hard.

This post is about how to practice TCR correctly. It ISN'T about the merits or deficiencies of TCR (although that would be an interesting topic for another post).

In TDD, you start with failing tests, make them pass, and then refactor. I know TCR != TDD, but I'm going to use TDD terminology for my question:

I can't tell if TCR is just "green, refactor" or if it is "red, green, refactor." It's not explicitly stated in the article.

Many times I've experienced situations where my test started green because I wrote the test wrong, that's why I always like to start with a red test — to give me confidence I'm testing what I really think I am.

TCR seems fascinating and I'd like to try it, but I want to make sure I'm actually trying it, not some bastardization I unintentionally created. So when practicing TCR, should I start with a failing test first?

Best Answer

Kent Beck actually answers this question himself if you watch a video of him teaching TCR. The answer is yes. You do skip "red" when you are practicing TCR.

I also found this article that directly states you skip the "red" of red, green, refactor when you practice TCR. And this TCR tool can only be used under that assumption.

I think that article is clear and concise. Here are two useful pictures from it:

TDD

enter image description here

TCR

enter image description here