13

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.

Neil
  • 1,754
  • 2
  • 17
  • 30

1 Answers1

21

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

krismath
  • 1,879
  • 2
  • 23
  • 41
Bill Venners
  • 3,549
  • 20
  • 15