Fork me on GitHub
#clojure-spec
<
2019-01-04
>
dacopare17:01:25

What's the best way to integrate spec with clojure.test? I want to run my spectest/checks as part of the test suite.

taylor18:01:49

I've used this pattern before, not sure if it's good or not:

(deftest foo-test
  (is (= 1 (-> (st/check `foo)
               (st/summarize-results)
               :check-passed))))

taylor18:01:31

doesn't give meaningful output on failure

cjsauer18:01:50

@dacopare Clojure.test.check has the clojure.test.check.clojure-test/defspec macro for that purpose. https://github.com/clojure/test.check

Alex Miller (Clojure team)18:01:48

that’s not going to help you here

borkdude18:01:06

@dacopare I’m using respeced (a lib I wrote). Here’s an example how I use it: https://github.com/borkdude/speculative/blob/master/test/speculative/core_test.cljc

avi19:01:19

I’ve got a few primitive functions to glue spec’s check and clojure.test together, along with expound; I originally copy-pasta’d them from a gist and then massaged mangled them over time: https://github.com/FundingCircle/fc4-framework/blob/master/tool/src/test_utils/fc4/test_utils.clj

avi19:01:05

(Oh cool, that snippet includes the entire file if you expand it. Too bad it doesn’t include syntax highlighting.)