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 s]))
(defn simple-fn []
"x")
(s/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 s]))
(s/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 --------------------
"x"
should satisfy
int?
-- Relevant specs -------
:simple/int:
clojure.core/int?
-------------------------
Detected 1 error
Can you improve this documentation?Edit on GitHub
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close