Kaocha Test Runner
LambdaIsland/Kaocha is a feature rich test runner for Clojure and ClojureScript.
Koacha is typically run on the command line or as part of a continuous integration workflow.
Kaocha can also be run as an alternative to the cider-test runner as the Spacemacs Clojure layer now includes kaocha-runner.el. Kaocha provides options to fail-fast (stops when a test fails) and
Using Kaocha from Emacs Cider
SPC f e d to edit the Spacemacs configuration file, adding
clojure-enable-kaocha-runner t as a variable to the Clojure layer.
Start a REPL process that includes the kaocha library
:lib/kaocha alias in practicalli/clojure-deps-edn includes Kaocha as a library
, t k a to run all tests
, t k t to run the deftest at point (under the cursor)
, t k n to run tests in the current namespace
, t k w to show warnings from the kaocha runner
, t k h to hide the kaocha test window
Kaochan runner uses kaocha.repl
kaocha-runner.el uses the the same appraoch as running Kaocha from the REPL
Using Kaocha from Command Line
Kaocha on the command line will run tests from the saved code files, so is very useful to run before committing files as well as during a Continuous Integration workflow.
practicalli/clojure-deps-edn defines aliases to run Kaocha from the
clojure -X:test/run will run all tests found in the project, unless there is a failing test which will end the test run.
clojure -X:test/watch runs all test and then watches for changes to the test code, running again if a change is detected.
Kaocha shell script
Kaocha install guide recommends creating an executable shell script file, i.e.
:test/run alias from practicalli/clojure-deps-edn (or create an alias in the project
test/run "$@"clojure -X:
Run the shell script to run all the tests
To continually watch a function, pass the watch argument
bin/kaocha :watch? true
Or define a binary that always watches, e.g.
bin/kaocha-watch using the
:test/watch alias from practicalli/clojure-deps-edn
test/watch "$@"clojure -X:
Configure kaocha in tests.edn
tests.edn in the root of a project can define the full range of options for Kaocha configuration options and is the preferred approach.
Continuous Integration workflow
:test/run alias to the project
deps.edn file and define kaocha configuration in a
tests.edn file in the root of the project.
Define a job that runs the tests that calls either the kaocha script or the
clojure command to run all the tests.