TCR stands for "test && commit || revert," a challenging and fun development workflow. It goes like this:
- Make some changes.
- Run tests.
- If the tests pass, it commits your changes.
- If the tests fail, it reverts your changes.
Clone this repo. Then in Xcode, open Settings and go to the Behaviors tab.
Under "Testing Succeeds" scroll down until you see a "Run" option. Select the tcr-commit.sh
script.
Under "Testing Fails" set the "Run" to the tcr-revert.sh
script.
Upon a successful test run, the commit script shows a dialog asking you for a commit message. Enter your commit message and press enter, and it will commit your changes.
Upon a test failure, the revert script will revert your changes. It deletes any new files. (Any files ignored by your repo will remain.) And it shows you a dialog to letting you know it did its business.
To bypass TCR, deselect the Run script in the Testing Fails behaviors. This will keep any changes in place.
You can keep the Run script in place for Testing Succeeds. If you leave the commit message blank, it won't make a commit.
- test && commit || revert original article by Kent Beck
Jon Reid is the author of iOS Unit Testing by Example. His website is Quality Coding.