Liking cljdoc? Tell your friends :D

Orchestra (spec instrumentation)

You can enable spec instrumentation of your functions before running tests with the :kaocha.plugin/orchestra plugin. This uses the Orchestra library to instrument :args, :ret, and :fn specs.

You can use the :kaocha.plugin/preloads plugin to ensure namespaces are required (similar to ClojureScript's preloads feature). This is useful to ensure that your specs required before the orchestra plugin instruments your functions.

Enabling Orchestra

  • Given a file named "tests.edn" with:
{:plugins [:orchestra
 :kaocha.plugin.preloads/ns-names [my.specs]
 :color? false}
  • And a file named "test/orchestra_test.clj" with:
(ns orchestra-test
  (:require [clojure.test :refer :all]
            [clojure.spec.alpha :as spec]))

(defn simple-fn []

(spec/fdef simple-fn :ret :simple/int)

(deftest spec-fail-test
  (is (= "x" (simple-fn)) "Just testing simple-fn"))
  • And a file named "src/my/specs.clj" with:
(ns my.specs
  (:require [clojure.spec.alpha :as spec]))

(spec/def :simple/int int?)
  • When I run bin/kaocha

  • Then the output should contain:

ERROR in orchestra-test/spec-fail-test (orchestra_test.clj:11)
Just testing simple-fn
Call to orchestra-test/simple-fn did not conform to spec.

-- Spec failed --------------------

Return value


should satisfy


-- Relevant specs -------


Detected 1 error

Can you improve this documentation? These fine people already did:
Arne Brasseur & Alys Brooks
Edit on GitHub

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close