Continuous testing for Ruby with fork/eval
Test Driven Development (TDD) is by no doubt a cornerstone of the modern Software Engineering discipline, especially in the Ruby programming world.
A few weeks ago, I felt that I had remained a TDD spectator for too long and decided to jump on the TDD bandwagon once and for all. Under TDD, my Ruby on Rails application progressed slowly but reliably and I experienced a newfound sense of confidence and euphoria whilst developing it.
Alas, the good times soon turned sour, as my tests took longer to run with each passing day (and the number of new tests I wrote therein). Things could not go on this way if I were to continue practicing TDD, so I began looking for ways of continuously running tests using the fork/eval approach, where the test execution overhead would be absorbed by the continuous testing daemon and my tests would thereby run very quickly.
I tried AutoTest
first, but soon noticed that it shelled-out to Ruby in order to run tests,
meaning that it did not absorb the test execution overhead as I hoped.
Instead, all it did was to automatically perform the equivalent of rake test
whenever my source files changed.
Next I tried Watchr, whose examples suggested that it, like autotest, was best for shelling-out to Ruby to run tests whenever my source files changed.
Finally, I gave up on the search and instead created my own continuous testing tool called test-loop which follows the forementioned fork/eval approach to speed up test execution. With this tool, I am now more productive with TDD than ever because my tests finish running within seconds after I save my source code! TDD FTW :-)