Fork me on GitHub
#test-check
<
2020-05-11
>
arohner12:05:55

What’s the best way to test properties on a collection? I typically write

(prop/for-all [in generator] (let [ret (foo in)] (every? (fn [r] ...) ret))
, and this works, but the output on failure isn’t very nice, because test.check doesn’t know how to show the offending element

arohner12:05:59

oh, one other wrinkle, the spec for each item is dynamic:

(every? (fn [m]
              (s/valid? (s/spec (::p/message-type m)) m)) msgs)

arohner12:05:34

so I can’t easily use (s/valid? (s/coll-of ::foo) msgs)

gfredericks13:05:46

> test.check doesn’t know how to show the offending element this can be remedied by returning a custom Result object

gfredericks13:05:14

you could imagine a helper for this, a variant of every? , provided by a library or test.check itself

gfredericks13:05:24

but the plumbing is there for getting better output