Neil
Neil

Reputation: 1948

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.

Upvotes: 13

Views: 8889

Answers (1)

Bill Venners
Bill Venners

Reputation: 3669

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

Upvotes: 21

Related Questions