Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@nwjsmith
Created February 20, 2018 18:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nwjsmith/69906cf0fda381d1b298ccb182e87d2d to your computer and use it in GitHub Desktop.
Save nwjsmith/69906cf0fda381d1b298ccb182e87d2d to your computer and use it in GitHub Desktop.
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