An old question, probably long since answered or worked around, but since I'm a scalacheck newbie trying to figure out the ropes, I'll volunteer a response.
Not sure why your example doesn't work as expected, but this simpler test does the trick (in Scalacheck 1.14):
import org.scalacheck.Properties
import org.scalacheck.Prop.{forAll,collect}
object AccountSpecWithMarkup extends Properties("AccountSpecWithMarkup") {
property("max") = forAll { (a: Int, b: Int) =>
collect((a, b)) {
a != b || a == b
}
}
}
Note that the test is now an object
extending Properties
. The Properties.property
val is of type PropertySpecifier
, which encapsulates mutable state (a collection of Props
) and has an update
method. This line
property("max") = forAll { ... }
is syntactic sugar for
property.update("max", forAll{ ... })
where the forAll
generates a value of type Prop
. This Prop
value is accumulated for later evaluation using implicit Arbitrary[Int]
generators to generate test values for a
and b
, which are collected by collect
for reporting in the test results.
Here's the first few lines of a successful test run
+ AccountsSpectWithMarkup.max: OK, passed 100 tests.
> Collected test data:
4% (-2147483648,2147483647)
2% (1,2147483647)
2% (-1,-1)
2% (-1,0)
1% (-1,-1128775662)
1% (501893471,-2147483648)
1% (0,0)
1% (1529964222,-1507103054)
1% (36753817,-2147483648)
1% (2147483647,535423354