Fork me on GitHub
#clojure-spec
<
2020-07-22
>
denis_krivosheev11:07:46

Hello everyone. I want to write some tests for my library but I really don’t want to write example based tests. I thought spec can be an instrument for property based testing, but couldn’t find a way to transform spec (or generator) into a test. Can someone please help me with that?

Alex Miller (Clojure team)12:07:41

With spec, the main way you do it is by writing function specs and running “check”

Alex Miller (Clojure team)12:07:17

Spec generators are also test.check generators so you can use test check property testing too

denis_krivosheev18:07:28

Oh this should work. Thank you very much

Alex Miller (Clojure team)18:07:14

in fact, I find using (s/gen a-spec) to often be easier than using test.check to create generators directly

borkdude13:07:56

@jahvenni https://github.com/arohner/spectrum is one attempt at this. I'm not sure if it's actively being worked on.