Note that this is all a little complex. The above link to “the ScalaTest way” isn’t actually the ScalaTest way – it’s ScalaTest-plus-ScalaCheck. So you are going to need both ScalaTest imports (for the extends FunSuite
and the test syntax) and ScalaCheck imports (for Generator
and forAll
and such).
OTOH, as of ScalaTest 3.1, similar functionality has been built into ScalaTest proper. That will be available as org.scalatest.prop._
IIRC. But it’s new enough (like, I was working on it in January) that you may not want to get into it right now.
(As @sangamon alludes to, one way to tell the difference between the two is that ScalaCheck uses Gen
, and the new ScalaTest version uses Generator
. There are a bunch of little differences like that in the details, but conceptually both systems do the same stuff.)