No timeout for tests returning Future[Assertion]

14 views
Skip to first unread message

Joaquin

unread,
Aug 17, 2017, 11:15:22 PM8/17/17
to scalate...@googlegroups.com
Hi all,

Thank you for the great work on Scalatest.

I recently discovered that, with AsyncFunSpec, when a test finishes
with a Future[Assertion], Scalatest will actually wait for the future
to complete to ensure that it is successful and the assertion
truthful.

Unfortunately I haven't found a way to only wait for a limited time,
which has the potential to make tests hang forever. PatienceConfig,
which works with whenReady, seems not to be taken into account here:

it("Unfortunately, PatienceConfig doesn't seem to be taken into
account when waiting for the returned Future[Assertion]"){
implicit val patienceConfig: PatienceConfig = PatienceConfig(
timeout = scaled(Span(5, Seconds)),
interval = scaled(Span(100, Millis))
)

Future[Int]{
Thread.sleep(1000 * 1000)
3
}.map(_ shouldBe 4)
}

The code above in context:

https://github.com/jcaraballo/scalatest-asyncfun-puzzlers/blob/da5018a530fb7fc79c8b412d1bb889e2cf960724/src/test/scala/casa/AsyncFunPuzzlersSpec.scala#L52-L62

Is this by design? A possible future feature?

Best regards,

--Joaquín
Reply all
Reply to author
Forward
0 new messages