【问题标题】:Scalatest: waiting for an assertion to become trueScalatest:等待断言变为真
【发布时间】:2014-08-26 14:00:42
【问题描述】:

scalatest 中是否存在任何需要等待一段时间才能使断言变为真的东西?

因此,例如,如果我有一个异步计算某些东西的线程,我想在我的测试中等待计算等于预期值。

【问题讨论】:

    标签: scala scalatest


    【解决方案1】:

    你很可能想要最终:

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

    但是如果你的计算是在一个未来中,你可能想要使用 Futures 子特征之一:

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

    【讨论】:

    • 非常感谢比尔 -- 最终正是我所需要的。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-03-10
    • 1970-01-01
    • 2017-01-08
    • 2016-05-14
    • 2014-11-16
    • 1970-01-01
    相关资源
    最近更新 更多