Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Instrumenting fixture.
(defn instrument-fixture-fn
"Returns a function to be used as a clojure.test fixture. The fixture will
instrument the vars named by sym-or-syms, a symbol or collection of symbols,
or all instrumentable vars if the sym-or-syms is not specified. Any
previously instrumented vars will be unstrumented before the test run and
re-instrumented afterwards. Takes the same arguments as
`clojure.spec.test.alpha/instrument`."
([] (instrument-fixture-fn (stest/instrumentable-syms)))
([sym-or-syms] (instrument-fixture-fn sym-or-syms {}))
([sym-or-syms opts]
(fn [f]
(let [unstrumented (stest/unstrument)]
(stest/instrument sym-or-syms opts)
(f)
(stest/unstrument sym-or-syms)
(stest/instrument unstrumented)))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment