speculative kaocha plugin
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.
bin Make plugin extensible to other test types (#1) Jan 31, 2019
src/speculative_kaocha Refactor test-suite? function, see #1 Jan 31, 2019
test/speculative_kaocha Initial commit Jan 30, 2019
.dir-locals.el Make plugin extensible to other test types (#1) Jan 31, 2019
.gitignore Initial commit Jan 30, 2019
LICENSE Initial commit Jan 30, 2019
README.md README Feb 8, 2019
deps.edn Version 0.0.1 Feb 8, 2019
package-lock.json Initial commit Jan 30, 2019
project.clj Bump version Feb 8, 2019
tests.edn Initial commit Jan 30, 2019


speculative kaocha plugin

Clojars Project cljdoc badge

This kaocha plugin instruments tests with speculative clojure.core specs.



{:deps {speculative/kaocha-plugin {:mvn/version "0.0.1"}}}

Leiningen / Boot

[speculative/kaocha-plugin "0.0.1"]


Add :speculative-kaocha.plugin/instrument to the :plugins key in tests.edn.

By default clojure.core functions are instrumented. This can be disabled by setting :speculative-kaocha.plugin/no-instrument to true on a per test suite basis.

{:plugins [:speculative-kaocha.plugin/instrument]
 :tests [{:id :unit
          :kaocha/test-paths    ["test/unit"]}
         {:id :integration
          :speculative-kaocha.plugin/no-instrument true
          :kaocha/test-paths    ["test/integration"]}]}


$ cat test/demo/core_test.cljc
(ns demo.core-test
  (:require [clojure.test :as t]))

(t/deftest foo
  (t/is (flatten 1)))

$ clojure -A:test -m kaocha.runner
1 tests, 1 assertions, 0 failures.

$ clojure -A:test -m kaocha.runner --plugin speculative-kaocha.plugin/instrument
Randomized with --seed 1206313428

ERROR in demo.core-test/foo (alpha.clj:132)
Exception: clojure.lang.ExceptionInfo: Call to #'clojure.core/flatten did not conform to spec.
{:clojure.spec.alpha/problems [{:path [:x :clojure.spec.alpha/pred], :pred clojure.core/sequential?, :val 1, :via [:speculative.specs/sequential], :in [0]} {:path [:x :clojure.spec.alpha/nil], :pred nil?, :val 1, :via [], :in [0]}], :clojure.spec.alpha/spec #object[clojure.spec.alpha$regex_spec_impl$reify__2509 0x76596288 "clojure.spec.alpha$regex_spec_impl$reify__2509@76596288"], :clojure.spec.alpha/value (1), :clojure.spec.alpha/fn clojure.core/flatten, :clojure.spec.alpha/args (1), :clojure.spec.alpha/failure :instrument, :clojure.spec.test.alpha/caller {:file "core.clj", :line 665, :var-scope clojure.core/apply}}

Selectively disabling specs

In the unfortunate event that a speculative spec is wrong, or your code is offending a spec and you don't want to fix it right away, you can selectively disable specs by def'ing them to nil after loading speculative.instrument.

E.g. (s/def clojure.core/re-find nil).

In deps.edn this can be done as follows:

["-e" "(require,'[speculative.instrument])"
 "-e" "(require,'[clojure.spec.alpha,:as,s])"
 "-e" "(s/def,clojure.core/re-find,nil)"
 "-m" "kaocha.runner" "--no-capture-output"]


clojure -A:test
lein kaocha


Copyright © 2018 Michiel Borkent

Distributed under the EPL License, same as Clojure. See LICENSE.