Mission of MaBe
High-quality, well designed, crafted and tested software.

About MaBe
Blog
TDD in Clojure with CIDER on Emacs

01/10/2019  |  Software  | 
 
I'm a Clojure beginner.
 
Clojure is a Lisp dialect running on the Java Virtual Machine.
 
It's an enormously interesting language.
Lisp is very old. It was developed in the 1960's. But it's actually not old. Functional programming languages see a new life. But I don't want to go into more detail on that.
 
In this blog I'll show you how to do Test-Driven Development in Clojure using Emacs.
There is an Emacs plugin called CIDER which makes development of Clojure in Emacs really good.
 
So here are some pre-requisites:
- you have to have Emacs
- install the CIDER plugin, see: https://cider.readthedocs.io/en/latest/
- install Leinigen, see https://leiningen.org
 
Btw: I’m assuming you know how to get around in Emacs with creating new buffers, etc.
 
Let’s get started:
 
The default test suite in Clojure is Clojure.test.
 
Usually you create test file in some subfolder of ‚test‘ in your project. 
import (:use) the clojure.test.
Now add a deftest and add some test code.
 
You run the tests in this buffer with this key-command: C-c C-t C-n.
However, and this was a blocker for me until I found out, you have to evaluate the buffer (and other buffers of imports).
Do this key-command to evaluate the buffer: C-c C-k.
 
After running the tests, CIDER will show you which tests failed by color highlighting.
 
But generally the workflow is this:
 
- add (test) code
- evaluate C-c C-k
- run tests C-c C-t C-n
 

Comments


Add comment