Created
February 20, 2018 18:20
-
-
Save nwjsmith/69906cf0fda381d1b298ccb182e87d2d to your computer and use it in GitHub Desktop.
Instrumenting fixture.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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