I was recently inspired by a post on a mailing list to make the TDD
lein-test-refresh is a Leiningen tool that monitors your
Clojure project’s source, reloads changes, and then runs your tests.
Tools like it provide some of the fastest feedback cycles possible.
To make the feedback cycle even faster I added the option to only run
tests in changed namespaces. This means you’re running
the minimum number of tests after a change. Version 0.12.0 of
lein-test-refresh was released earlier this week with this feature.
To use it add
[com.jakemccrary/lein-test-refresh 0.12.0] as a plugin
to your profiles.clj or project.clj. An example
can be found in the project’s GitHub repo.
Once you’re on the latest version you can toggle this feature from the
command line by providing a
:changes-only, or by adding
:changes-only true to your
:test-refresh configuration section in your project.clj or
profiles.clj. When the feature is on you can still run all your tests
enter in the terminal running
Below is an example of the time difference between running all my tests and the tests in a single namespace.
1 2 3 4 5 6 7 8 9 10 11 12 13 14
I’ve been using this feature for about a week now and am enjoying it. My whole test suite isn’t particularly slow but even still I’ve been enjoying the faster feedback.