2019 TCR - SoCraTesUK/socrates-uk GitHub Wiki

test && commit || revert (TCR)

Reading:

What?

Replace the red -> green -> refactor cycle with the TCR cycle: write test + implementation, if it's green commit and continue, if it's red revert and start again with writing a test.

You are only allowed to run tests through this cycle! Running tests in your IDE without the 'risk' of a revert is considered cheating.

Howto

Script way

Create a script for your TCR cycle, to make this an atomic action! For gradle + git, it could be something like:

./gradlew test && git commit -am working || git reset --hard

Adapt to your environment as needed.

Test both the commit and revert case before starting, to fix potential issues with your script! Also keep in mind that your IDE might keep files cached in memory.

IntelliJ plugin

Alternatively, you can use the Limited WIP IntelliJ plugin: https://plugins.jetbrains.com/plugin/7655-limited-wip

Learnings

Yorgos (@gsaslis)

  • Really forced to follow baby-steps approach: over time, it feels like the tcr command would become the equivalent of "running the tests", so I'd be forced to only make small changes I'm confident about.
  • Wondering how one handles commit history
  • setup took a bit of time - a starting point, for next time I get round to doing this, would probably help get more done in 1h.

Facilitating TCR as code retreat

Make sure everyone gets into the loop as soon as possible! This means that Game of Life might be too hard an exercise to get started. It might be better to use a TDD kata like the bowling game kata?