Infinite shrinking when using inside and property based tests with filters

5 views
Skip to first unread message

Jason Steenstra-Pickens

unread,
Sep 16, 2016, 10:44:15 AM9/16/16
to scalatest-users
Hi,

I'm trying to use ScalaTest with property based tests.

My test looks something like this:
class MySpec extends FlatSpec
                     with Matchers
                     with PropertyChecks
                     with Inside {

  "inside" should "work with property based testing" in {
    forAll { (value: String) =>
      whenever(value.trim.nonEmpty) {
        println(value)
        val sut: Option[String] = None // Force a failure
        inside(sut) { case Some(thing) =>
          value shouldBe thing
        }
      }
    }
  }
}

In this example I have intentionally made the test fail. In my real test I was really hoping to use pattern matching since the actual type is not an Option but some other hierarchical case class and I don't want to use equality.

It seems that this gets stuck in a loop where it looks like it is trying to shrink the failure down. If I remove the whenever then it works as expected.

Shall I raise this as a bug? (I'm using ScalaTest 3.0.0)


Cheers,
Jason

Bill Venners

unread,
Sep 16, 2016, 10:50:19 AM9/16/16
to scalate...@googlegroups.com
Hi Jason,

Sorry I missed the notification that you had posted this question. That does look like a bug, so please report it as an issue if you haven't already.

Bill

--
You received this message because you are subscribed to the Google
Groups "scalatest-users" group.
To post to this group, send email to scalatest-users@googlegroups.com
To unsubscribe from this group, send email to
scalatest-users+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/scalatest-users?hl=en
ScalaTest itself, and documentation, is available here:
http://www.artima.com/scalatest
---
You received this message because you are subscribed to the Google Groups "scalatest-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scalatest-users+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Bill Venners
Artima, Inc.
http://www.artima.com
Reply all
Reply to author
Forward
0 new messages