Full featured next generation test runner for Clojure.
Project | CI | Docs | Release | Coverage |
---|---|---|---|---|
kaocha | ||||
kaocha-cljs | ||||
kaocha-cucumber | ||||
kaocha-junit-xml | ||||
kaocha-cloverage | ||||
kaocha-boot | ||||
deep-diff |
See the Line Dict entry for an audio sample.
kaocha is part of a growing collection of quality Clojure libraries and tools released on the Lambda Island label. If you are using this project commercially then you are expected to pay it forward by becoming a backer on Open Collective, so that we may continue to enjoy a thriving Clojure ecosystem.
Are you
There is also a #kaocha channel on Clojurians Slack (sign up here), where users can help each other.
clojure.test
assertion extensions--fail-fast
option--profile
option--reporter
optionFeatures include
This is no replacement for reading the docs, but if you're particularly impatient to try it out, or if you already know Kaocha and need a quick reference how to set up a new project, then this guide is for you.
Add Kaocha as a dependency, preferably under an alias.
;; deps.edn
{:deps { ,,, }
:aliases
{:test {:extra-deps {lambdaisland/kaocha {:mvn/version "1.0.732"}}}}}
Add a binstub called bin/kaocha
mkdir -p bin
echo '#!/usr/bin/env sh' > bin/kaocha
echo 'clojure -A:test -m kaocha.runner "$@"' >> bin/kaocha
chmod +x bin/kaocha
Add a profile and alias
;; project.clj
(defproject my-proj "0.1.0"
:dependencies [,,,]
:profiles {:kaocha {:dependencies [[lambdaisland/kaocha "1.0.732"]]}}
:aliases {"kaocha" ["with-profile" "+kaocha" "run" "-m" "kaocha.runner"]})
Add a binstub called bin/kaocha
mkdir -p bin
echo '#!/usr/bin/env sh' > bin/kaocha
echo 'lein kaocha "$@"' >> bin/kaocha
chmod +x bin/kaocha
In your build.boot
add the Kaocha dependency, and import the Kaocha task
;; build.boot
(set-env! :source-paths #{"src"}
:dependencies '[[lambdaisland/kaocha-boot "..."]])
(require '[kaocha.boot-task :refer [kaocha]])
Add a binstub called bin/kaocha
mkdir -p bin
echo '#!/usr/bin/env sh' > bin/kaocha
echo 'boot kaocha "$@"' >> bin/kaocha
chmod +x bin/kaocha
By default, Kaocha assumes that:
src/
folder,test/
folder,-test
(e.g. my-project.core-test
).
Also, the default test suite id is :unit
(just unit
on the command line).If your tests don't seem to run (outcome is 0 tests, 0 assertions, 0 failures
)
you may need to write up your own configuration: add a tests.edn
at the root
of the project to configure actual test and source paths, and optionally set a
reporter or load plugins (cf. Configuration in the
documentation).
Example of a catch-all tests.edn
config file (should run all
tests found in src/
and /test
, in any namespace).
#kaocha/v1
{:tests [{:id :unit
:test-paths ["test" "src"]
:ns-patterns [".*"]}]}
;; :reporter kaocha.report.progress/report
;; :plugins [:kaocha.plugin/profiling :kaocha.plugin/notifier]
}
Warning: this is not an optimal configuration. To avoid extra churn, you should try and target only folders and namespaces that actually contain tests.
Run your tests
bin/kaocha
# Watch for changes
bin/kaocha --watch
# Exit at first failure
bin/kaocha --fail-fast
# Only run the `unit` suite
bin/kaocha unit
# Only run a single test
bin/kaocha --focus my.app.foo-test/bar-test
# Use an alternative config file
bin/kaocha --config-file tests_ci.edn
# See all available options
bin/kaocha --test-help
(is (= actual expected))
instead of (is (= expected actual))
Kaocha requirements Clojure 1.9 or later.
Everyone has a right to submit patches to kaocha, and thus become a contributor.
Contributors MUST
*
**
Contributors SHOULD
If you submit a pull request that adheres to these rules, then it will almost certainly be merged immediately. However some things may require more consideration. If you add new dependencies, or significantly increase the API surface, then we need to decide if these changes are in line with the project's goals. In this case you can start by writing a pitch, and collecting feedback on it.
*
This goes for features too, a feature needs to solve a problem. State the problem it solves, then supply a minimal solution.
**
As long as this project has not seen a public release (i.e. is not on Clojars)
we may still consider making breaking changes, if there is consensus that the
changes are justified.
Copyright © 2018-2020 Arne Brasseur and contributors
Available under the terms of the Eclipse Public License 1.0, see LICENSE.txt
Can you improve this documentation? These fine people already did:
Arne Brasseur, François De Serres, Rick Moynihan, Matthew Boston, Alys Brooks, fdserr, Joel Kaasinen, The Alchemist, A Brooks, Daniel Compton, José Luis Lafuente & Jose V. TriguerosEdit on GitHub
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close