Fork me on GitHub

@scott.silver asked this in #cider: I'm also curious what's your approach with stest/instrument and evaluating a clojure buffer since it must be a problem with other editors too. In short, after you evaluate a ns buffer all the instrumentation is gone and you need to call instrument again manually which is cumbersome and easy to forget. Developers then commit spec errors which are only found much later, etc.


If I'm using instrument with dev/test, I have a call to instrument as part of each test namespace. See (and similar lines in every test ns in next.jdbc).


You could make it part of you fixtures if you wanted to ensure it was added for every test you ran via the REPL from your editor but I think this is enough to ensure a full test run uses specs.


Interesting, but I'm more worried about real "src" namespaces, rather than tests... do you have instrument calls there as well?


No. Why would you?


You want instrumentation in place for testing, not production.

Scott Silver17:06:22

I agree that you don’t want it in production, but it’s very useful in dev, not just in test, yeah?


I run tests during dev so... 🙂


(also, I only spec API boundaries in general, or functions that have some unusual aspects -- we have over 600 specs in our code but only 30-some function specs)

Scott Silver18:06:08

do you run tests manually while developing? or do you use something like lein-test-refresh to run the test suite when you make changes?


I have hot keys bound to run: a) all tests in the current namespace b) all tests in a test namespace that corresponds to the current namespace c) the test under the cursor


So it is manual but very easy. I don't use lein at all and I don't like watcher-based tasks or any sort of reload/refresh workflow.

👍 3

We enable instrumentation for all fdef-s in dev mode (when running in REPL) to catch issues early - it's not enabled in production


I am assuming the following ways to define a spec are equivalent ? The seem to provide the same results with confirm/valid? etc.

(def suit? #{:clubs :diamonds :hearts :spades})
(spec/def ::suit #{:clubs :diamonds :hearts :spades})
Is it overkill to define a spec for a set as it already acts as predicate function? Or does it make little or no difference?


either is fine. s/form probably works better with sets

👍 6