forAll in ScalaCheck doesn't run the body

This is the code that tests the surface area of a rectangle with random integers for the coordinates and sizes. Only "begin" will be printed and never "inner body". Does anyone know what I did wrong or forget?

package de.thm.move.shapes
import de.thm.move.views.shapes.ResizableRectangle
import org.scalacheck.*
import de.thm.move.MoveSpec

class ResizableRectangleTest extends MoveSpec {

  "Rectangle area procedure" should "give the correct area" in{
    val intPositiveDomain = Gen.choose[Int](1, 10000) //for the coordinates of the shape
    val intDomain = Gen.choose[Int](-10000, 10000) //for the size of the shape

    //will test for random values for the coordinates and the size of the shape
    val popRectangle =  Prop.forAll(intDomain,intDomain,intPositiveDomain,intPositiveDomain) { (x: Int, y: Int, width: Int, height: Int) =>
      val rectangle: ResizableRectangle = new ResizableRectangle((x.toDouble, y.toDouble), width.toDouble, height.toDouble)
      val correctSurface: Double = width.toDouble * height.toDouble
      println("inner body")
      rectangle.getSurfaceArea() == correctSurface


I excpected many prints of "inner body" but I get zero.

Run console: the run console


  • Prop.forAll just creates a Prop object, it doesn't actually execute anything. To actually check the property, you'll need to call the check method.