clojure-spec

About: http://clojure.org/about/spec Guide: http://clojure.org/guides/spec API: https://clojure.github.io/spec.alpha/clojure.spec.alpha-api.html
denis_krivosheev 2020-07-22T11:25:46.018100Z

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?

alexmiller 2020-07-22T12:43:41.019100Z

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

alexmiller 2020-07-22T12:45:17.020200Z

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

alexmiller 2020-07-22T12:46:05.020500Z

https://clojure.org/guides/spec covers using check

borkdude 2020-07-22T13:56:56.021Z

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

denis_krivosheev 2020-07-22T18:43:28.022300Z

Oh this should work. Thank you very much

alexmiller 2020-07-22T18:47:14.022500Z

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