test && commit || revert

TDD
Courtesy: Geek and Poke

This post by the legendary Kent Beck describes an extreme form of TDD. In all fairness, I haven't tried it and your mileage may vary.

Although, my biggest takeaway from this article was:

"I hated the idea so much that I had to try it"

The idea behind TCR (Test & Commit Or Revert) strategy is simple. Run a loop to commit code the moment all the test cases pass. If the tests don't pass, revert the code to the last commit where the tests pass.

while(true);
do
git pull --rebase;
(test && git commit -am working) || git revert;
git push;
done;
  • This strategy ensures that all changes are done incrementally in small batches. No big diffs.
  • Fewer conflicts between developers on the team because they are constantly pulling each other's code.
  • Insane out-of-the-box idea that might actually work.

Obviously, give it a shot in a smaller toy project first before trying this in your 2 million line code base that powers the stock market. I know I am.

Full Post here, 3 mins read