Continuous test runs

Yesterday in Mechelen, at the pair programming party, Rob westgeest and I tried out a different way of running tests often. We were working on a  mini-feature in Hourensou We had been having some trouble with the tests before. We were using a freshly installed machine, with only a couple of simple text editors (scite and gedit) present. We wanted to run the tests often. However, I dislike having to switch from window to window all the time (in this case, switching from an editor window to a terminal window with the tests).

Therefore, we tried something simple: run all the tests in a loop, continuously. That way, if we saved, we only had to wait a little while for the tests to run of their own accord. The loop was written in bash shell script, so we get a fresh ruby interpreter each time the tests are run (the alternative was to use irb, the interactive ruby interpreter with a loop around a bunch of ‘require’ statements). We used ‘nice’ to make the tests run at a lower priority than our other processes. The tests are contained (in this case) in all.rb:

while true; do nice ruby all.rb ; done

Having the tests run all the time had an interesting effect. We were even more motivated than usual to make all the tests run, and errors were spotted quickly – just sit back for a moment, relax, and watch the testsrun. Reading the failure messages was a bit more difficult though; as the tests keep on running the results keep scrolling upwards.

I don’t know a simple way (yet) how to run tests only if files are modified. Possibly a rakefile could work, but that’s already a lot more work than the one line of bash script we came up with as the simplest thing that could possibly work.

Comments are closed.