The 2.2.0 release1
of
expectations adds
a
clojure.test
compatible syntax. The release
adds the defexpect
macro which forces you to name your test but then
generates code that is compatible with clojure.test
.
Why would you want this? Because clojure.test
is the built-in
testing library for Clojure, an entire ecosystem has been built around
it. Tool support for clojure.test
is always going to be ahead of
support for the original expectations
. By using the new
clojure.test
compatible syntax, expectations
can take
advantage of all the tools built for clojure.test
.
Using lein-test-refresh with expectations
If you move to the new clojure.test
compatible syntax, you can start
using
lein-test-refresh to
automatically rerun your tests when your code
changes. lein-test-refresh
is a fork of the original expectations autorunner, lein-autoexpect, but it has grown to have more features than its original inspiration. Now you can use it with expectations
2.
Below is a sample project.clj
that uses lein-test-refresh
with the latest expectations.
1 2 3 4 5 |
|
Here is an example test file.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
|
And here is the result of running lein test-refresh
.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
|
After some quick edits to fix the test errors and saving the file, here is the output from the tests re-running.
1 2 3 4 5 6 7 8 9 10 11 12 13 |
|
If you’re using expectations
and switch to the new
clojure.test
compatible syntax, I’d encourage you to start
using
lein-test-refresh.