Full featured next gen Clojure test runner
Clone or download
Latest commit 0bd4f9d Nov 15, 2018

README.md

Kaocha

Full featured next generation test runner for Clojure.

Projects

Project CI Docs Release Coverage
kaocha CircleCI cljdoc badge Clojars Project codecov
kaocha-junit-xml CircleCI cljdoc badge Clojars Project codecov
kaocha-cloverage CircleCI cljdoc badge Clojars Project codecov
kaocha-cucumber CircleCI cljdoc badge Clojars Project codecov

Docs

Features

Features include

  • Filtering tests based on test names or metadata
  • Watch mode: watch the file system for changes and re-run tests
  • Pretty, pluggable reporting
  • Randomize test order
  • Detect when interrupted with ctrl-C and print report
  • Fail fast mode: stop at first failure and print report
  • Profiling (show slowest tests)
  • Dynamic classpath handling
  • Tests as data (get test config, test plan, or test results as EDN)
  • Extensible test types (clojure.test, Midje, ...)
  • Extensible through plugins
  • Tool agnostic (Clojure CLI, Leiningen, ...)

Quick start

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 "0.0-266"}}}}}

Add a wrapper/binstub

mkdir -p bin
echo '#!/bin/bash' > bin/kaocha
echo 'clojure -A:test -m kaocha.runner "$@"' >> bin/kaocha
chmod +x bin/kaocha

Add a tests.edn at the root of the project, add a first test suite with test and source paths. Optionally set a reporter or load plugins.

#kaocha/v1
{:tests [{:id :unit
          :test-paths ["test/unit"]
          :source-paths ["src"]}]
 ;; :reporter kaocha.report.progress/progress
 ;; :plugins [kaocha.plugin/profiling]
 }

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

Requirements

Kaocha requirements Clojure 1.9 or later.

License

© Arne Brasseur 2018

Available under the terms of the Eclipse Public License 1.0, see LICENSE.txt