Search code examples
scalascalatestscalacheck

Property test value is ignored by scalatest


This one is driving me nuts. The following property test passes in scalatest (using "sbt test" target).

import org.scalatest.FlatSpec
import org.scalatest.prop.PropertyChecks

class FigaroCheckSpec extends FlatSpec with PropertyChecks {
  "this property" should "fail" in { forAll { (p :Int) => false } }
}

Why? I tried both with FlatSpec and with FreeSpec. It also works (that is it fails) when I use Checkers with the scalacheck API directly.


Solution

  • You do not have a check/assertion in there, try this:

    "this property" should "fail" in { forAll { (p :Int) => assert(false) } }