Configure Cider Test runnerλ︎
Cider test runner provides a convenient way to run Clojure unit tests from within Emacs.
Source and test code is evaluated and the Cider test runner calls the deftest
functions to run all the tests. The results of the test run are shown in Emacs, along with a failure report if appropriate.
The test
directory must be included in the classpath when running the REPL, otherwise the CIDER test runner will not find the deftest
definitions.
Test directory should only added via an alias
The test
path should not be part of the main :paths
configuration, otherwise test code would be included in the jar or uberjar package and deployment.
Use .dir-locals.el to set default aliases when starting the REPL
A .dir-locals.el
is an Emacs project configuration file which can set any number of aliases that are automatically included when calling the Cider jack-in command.
Aliasesλ︎
Use an alias to include the test
directory and libraries that support testing.
Practicalli Clojure CLI Config contains several aliases to support the running of tests with the CIDER test runner.
:test/env
adds the test
directory to the class path and enables CIDER test runner to find the test code. This is the only alias required if using Cider test runner.
:lib/kaocha
add the kaocha test runner library to the class path, so kaocha can be used instead of CIDER test runner.
Other aliases can be used with the :test/env
alias to support cider-connect approach:
:repl/cider
include the nrepl and cider-nrepl libraries and starts an nREPL server connected to the REPL
:repl/rebel
run Rebel Readline, providing a rich terminal UI for the REPL
CIDER connectλ︎
Use cider-connect
to connect Emacs CIDER to the Clojure REPL process via its nREPL server, started in a terminal window with the following command:
Or for a richer terminal UI experience, use the :repl/rebel
alias to start a REPL & nREPL server:
Alias to run a simple Terminal UI REPL with nREPL supportλ︎
Run a REPL using nREPL server that starts an nREPL server, enabling CIDER to connect via cider-connect-clj
:repl/basic
{:extra-deps {nrepl/nrepl {:mvn/version "1.3.1"}
cider/cider-nrepl {:mvn/version "0.55.7"}}
:main-opts ["--main" "nrepl.cmdline"
"--middleware" "[cider.nrepl/cider-middleware]"
"--interactive"]}
Headless REPL
Remove the "-i"
if a headless (non-interactive) REPL is required, useful if only interacting with Clojure code via the nREPL connected editor.
Alias to run a Rebel REPL with nREPL supportλ︎
Rebel readline provides a rich terminal UI with nrepl server , enabling CIDER to connect via cider-connect-clj
:repl/rebel
{:extra-deps {nrepl/nrepl {:mvn/version "1.3.1"}
cider/cider-nrepl {:mvn/version "0.55.7"}
com.bhauman/rebel-readline {:mvn/version "0.1.5"}}
:main-opts ["--eval" "(apply require clojure.main/repl-requires)"
"--main" "nrepl.cmdline"
"--middleware" "[cider.nrepl/cider-middleware]"
"--interactive"
"-f" "rebel-readline.main/-main"]}
practicalli/clojure-cli-config contains common tools and aliases
practicalli/clojure-cli-config contains aliases for all aspects of Clojure development with the CLI tools.
Using Cider Connectλ︎
Start the REPL in a terminal including the test
directory and starting an nREPL server for CIDER to connect too.
Alternatively, use a rich terminal UI for the REPL using Rebel Readline which will also start an nREPL server for Cider to connect too.
Using CIDER jack-inλ︎
.dir-locals.el
file can define aliases which are always included during cider-jack-in
.
Add the variable cider-clojure-cli-aliases
with a names of one or more alias names, which are from either the project deps.edn
file or the user level deps.edn
configuration.
SPC p e
creates or opens an existing .dir-locals.el
file for the current project.
Remember to SPC b R
(revert-buffer
) on an existing project buffer, or open a file from the current project, to force Emacs to load in any changes to a .dir-locals.el
file.
Project configuration with .dir-locals.el
Project level configuration section contains many example configurations that can be set via .dir-locals.el
file.
Remember to revert-buffer
an existing project buffer or open a new buffer to load in changes from the .dir-locals.el
file.
Edit the jack-in commandλ︎
SPU u , '
uses the Emacs universal argument with sesman-start
and displays the command line to be run.
Add :test/env
directly after the -M
flag and before the :cider/nrepl
alias
SPC u
is the Spacemacs equivalent ofC-u
in Emacs.
Checking the jack-in commandλ︎
SPC b m
opens the messages buffer and the full command should be shown in the messages history.