Stathis Sideris — Blog

published: 14 Jul 2014

Clojure lein test-refresh notification workflow

Leiningen's test-refresh plugin can speed up your Clojure development by continuously running your tests in the background. It watches your project files for changes and re-runs the tests, and it even tries to provide you with feedback as quickly as possible by running the failed tests first. The first time it runs it can take a bit of time, but once it warms up it's pretty quick.

I have added test-refresh to my ~/.lein/profiles.clj file like so:

{:user {:plugins [[com.jakemccrary/lein-test-refresh "0.5.0"]]}}

You can then start test-refresh from another terminal with:

lein test-refresh

Another significant advantage of this workflow is that you also get instant compilation errors, which is not otherwise possible when you are using Emacs as your development environment.

To make the compilation and test feedback more apparent, you can use the notification options supported by test-refresh. It supports growl out of the box. I do my development inside a VM, so I run Emacs via tmux and I run test-refresh in another tmux window. In order to get test-refresh notifications in the tmux status line, you can change profiles.clj like so:

{:user {:test-refresh {:notify-command ["tmux" "display-message"]
                       :notify-on-success true}
        :plugins [[com.jakemccrary/lein-test-refresh "0.5.0"]]}}

This flashes a message everytime test-refresh finishes. I also had to add the following line to my .tmux.conf to get the message to appear for 4 seconds (the tmux default is 750msec):

set-option -g display-time 4000

It's all very easy and it takes us up to the level where IntelliJ was 10 years ago! :-)

blog comments powered by Disqus