Custom Generators with Specs2 ScalaCheck integration

90 views
Skip to first unread message

Gary Malouf

unread,
May 5, 2015, 5:30:21 PM5/5/15
to specs2...@googlegroups.com
So far, if I've wanted to use custom generators I used the Prop.forAll function explicitly in my examples.  I'm wondering if there is a straightforward, more integrated way of getting this behavior.

etorreborre

unread,
May 5, 2015, 8:03:56 PM5/5/15
to specs2...@googlegroups.com
Hi Gary,

There is a way to pass your custom generator:

prop((s: String) => s must contain("a") or contain("b")).setGen(abStringGen)

And if you have several arguments to your property you can specify .setGen1 for the first argument, .setGen2 for the second and so on.

Eric.

Gary Malouf

unread,
May 6, 2015, 10:42:30 AM5/6/15
to specs2...@googlegroups.com
Thanks Eric, this is exactly what I was looking for.

--
You received this message because you are subscribed to a topic in the Google Groups "specs2-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/specs2-users/_wAdZCFM9PA/unsubscribe.
To unsubscribe from this group and all its topics, send an email to specs2-users...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages