Fork me on GitHub
#clojure-spec
<
2019-10-18
>
ag17:10:44

what’s the idiomatic way to assert results of stest/check?

taylor18:10:19

not sure how idiomatic this is but

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

ag18:10:50

okay, but let’s say it returns nil and I want to print that out with expound, I guess I’m gonna have to run st/check one more time?

taylor18:10:05

not sure about the expound part

ag18:10:40

(expound/explain-results (stest/check `foo))
would print out the reason in human readable form, right? But it doesn’t return anything, so no way to assert it. and I can’t do something like:
(let [chk (stest/check `foo] ,,,
to re-use it for both

ag18:10:13

for assertion and for human-readable output

taylor18:10:18

I’ve never tried to use expound with test.check output

taylor18:10:45

which part doesn’t return anything?

taylor18:10:29

explain-results? you could use

(doto (stest/check `foo) expound/explain-results)
if so

ag18:10:05

ah yeah, nifty doto. Cool, thanks!

👍 4
ag18:10:39

ah, the problem with doto approach though - stest/check throws on failure… damn

taylor18:10:18

hmm really? maybe I’m thinking of something else but I thought it returned a map with useful failure info

taylor18:10:29

or maybe that’s in the exception

ag18:10:15

can someone show me an example of deftest where combination of stest/check used with expound

ag18:10:00

Oh… wow… this is pretty cool.

bbrinck18:10:19

Haven’t tried it yet, but it’s on my list.

ag18:10:02

Really awesome ideas, thank you guys!

bananadance 4
kszabo18:10:22

we use Kaocha’s feature, it works very well