package examples
import org.scalacheck._
import org.specs2._
import specification._
import execute.Result
class ScalaCheckScopeSpec extends Specification with ScalaCheck { def is =
"check something with before code" ! SC { (s: String) =>
s.reverse === s
}
object SC extends ScalaCheckContext with Before {
def before { println("before") }
override def checkProp(p: Prop) = p.set(minTestsOk -> 200)
}
}
// this trait would be provided by specs2
trait ScalaCheckContext extends ScalaCheck { this: Context =>
def apply[T, P](f: T => P)(implicit toProp: (=>P) => Prop, arbitrary: Arbitrary[T], shrink: Shrink[T]): Result = {
apply(checkProp(check(f)))
}
// this method can be overriden to provide specific ScalaCheck parameters
def checkProp(p: Prop) = super.check(p)
}
Please try it out a bit and tell me how it works for you.
Thanks,
Eric