This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-10-28
Channels
- # aleph (3)
- # beginners (10)
- # boot (135)
- # clara (2)
- # cljsjs (2)
- # cljsrn (1)
- # clojure (68)
- # clojure-austin (4)
- # clojure-france (2)
- # clojure-japan (1)
- # clojure-spec (30)
- # clojure-uk (11)
- # clojurescript (48)
- # component (65)
- # cursive (5)
- # datomic (40)
- # dirac (5)
- # emacs (3)
- # events (16)
- # funcool (2)
- # klipse (46)
- # lein-figwheel (2)
- # luminus (8)
- # off-topic (4)
- # om (7)
- # other-languages (4)
- # parinfer (21)
- # re-frame (15)
- # reagent (30)
- # ring (1)
- # ring-swagger (9)
- # rum (3)
- # specter (7)
- # test-check (8)
- # testing (5)
- # vim (21)
- # yada (4)
{:spec
(fspec :args (cat :m :runbld.store/es-opts) :ret string? :fn nil),
:sym runbld.store/make-connection,
:failure #error {
:cause "clojure.test.check.generators.Generator cannot be cast to clojure.lang.IFn"
:via
[{:type java.lang.ClassCastException
:message "clojure.test.check.generators.Generator cannot be cast to clojure.lang.IFn"
:at [clojure.spec$map_spec_impl$reify__13764 gen_STAR_ "spec.clj" 821]}]
:trace
[[clojure.spec$map_spec_impl$reify__13764 gen_STAR_ "spec.clj" 821]
[clojure.spec$gensub invokeStatic "spec.clj" 269]
[clojure.spec$re_gen invokeStatic "spec.clj" 1565]
[clojure.spec$re_gen$ggens__14211$gen__14212 invoke "spec.clj" 1554]
[clojure.core$map$fn__6882 invoke "core.clj" 2739]
[clojure.lang.LazySeq sval "LazySeq.java" 40]
[clojure.lang.LazySeq seq "LazySeq.java" 49]
[clojure.lang.RT seq "RT.java" 525]
[clojure.core$seq__6416 invokeStatic "core.clj" 137]
which comes from this fdef
(s/fdef make-connection
:args (s/cat :m ::es-opts)
:ret string?)
(defn make-connection
[args]
(http/make args))
I was getting that exception for a with-gen
in a separate place and kept thinking it was the same place
What are folks' thoughts on generative testing w/ spec on stateful fns (in this case modifying an atom)? How do you setup enough variations on the state for meaningful tests? Or is the answer that I should go to test.check
directly instead of relying on what clojure.spec
generates?
@cap10morgan: I haven’t done anything stateful yet, but if I had special generative needs, I’d reach for passing a custom generator in with-gen
first. If I understand you correctly, this is what you’re reaching for with the idea to use test.check
directly.
@bhagany OK, thanks. You answered my next question too. 🙂
@cap10morgan I’d try to separate the logic from the state and test the logic separately if possible.
@seancorfield Hmm, that's a good idea. I need to get into the habit more often. Thanks!
I was just having a similar conversation in #component 🙂
how do you figure out which spec or gen is problematic when you get Couldn't satisfy such-that predicate after 100 tries.
I think alexmiller has mentioned that as a pain point, that error comes out of test.check and plumbing the spec information through from spec to test.check and back again hasn't been done
if I recall, the way generators for s/and specs are constructed is you take the generator for the first spec in the s/and, and then such-that the rest of the specs (as predicates)
so if you have a really generic first thing, and more specific predicates afterwards, you can easily end up with a such-that that doesn't work
there is an exactly almost the same as this in the spec guide http://clojure.org/guides/spec
that shows how to make a custom generator for it
@alexmiller it wasn't that I misunderstood the spec, I just couldn't find the problematic one