I am trying to solve two problems of ScalaCheck (+ specs2):
For example, I would like to create about 10 random strings that include both alphanumeric and Unicode characters. However, this code always generates 100 random strings, and they are strictly alpha characters:
"make a random string" in {
def stringGenerator = Gen.alphaStr.suchThat(_.length < 40)
implicit def randomString: Arbitrary[String] = Arbitrary(stringGenerator)
"the string" ! prop { (s: String) => (s.length > 20 && s.length < 40) ==> { println(s); success; } }.setArbitrary(randomString)
}
Edit
I just realized that there is another problem:
- Often ScalaCheck refuses, without generating 100 test cases.
Of course, I do not want 100, but, apparently, my code is trying to create too complex a set of rules. The last time he ran, I saw that "surrendered after 47 tests."