Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Scalatest: waiting for an assertion to become true

Is there anything that exists in scalatest that will wait for a period of time for an assertion to become true?

So, for example, if I have a thread that computes something asynchronously, I want to wait in my test for the computation to equal the expected value.

like image 390
Neil Avatar asked Jul 05 '14 15:07

Neil


1 Answers

You most likely want Eventually:

https://www.scalatest.org/scaladoc/3.2.6/org/scalatest/concurrent/Eventually.html

But if your computation is inside a future, you would probably want to use one of the Futures subtraits:

https://www.scalatest.org/scaladoc/3.2.6/org/scalatest/concurrent/Futures.html

like image 123
Bill Venners Avatar answered Sep 20 '22 02:09

Bill Venners