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.
#kaocha/v1
{:plugins [:orchestra
           :preloads]
 :kaocha.plugin.preloads/ns-names [my.specs]
 :color? false}
(ns orchestra-test
  (:require [clojure.test :refer :all]
            [clojure.spec.alpha :as spec]))
(defn simple-fn []
  "x")
(spec/fdef simple-fn :ret :simple/int)
(deftest spec-fail-test
  (is (= "x" (simple-fn)) "Just testing simple-fn"))
(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.
orchestra_test.clj:11
-- Spec failed --------------------
Return value
  "x"
should satisfy
  int?
-- Relevant specs -------
:simple/int:
  clojure.core/int?
-------------------------
Detected 1 error
Can you improve this documentation? These fine people already did:
Arne Brasseur & Alys BrooksEdit on GitHub
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs | 
| ← | Move to previous article | 
| → | Move to next article | 
| Ctrl+/ | Jump to the search field |