我想知道recoverToSucceededIf在测试中的等价性。实际上,github页面显示了runAsync方法,AFAIK是TestRunner方法。
诚挚的问候
发布于 2017-10-12 12:17:52
我目前已经创建了一个特性来扩展utest,但是它肯定有一个本地方法。我不会把这作为一个答案,因为这只是一个解决办法。
import scala.concurrent.Future
trait UTestExt {
def recoverToSucceededIf[T <: Throwable: Manifest](f: => Future[Any]): Unit = {
import scala.concurrent.ExecutionContext.Implicits.global
f.map(_ => false).recover {
case _: T => true
case _ => false
} foreach (assert(_,
manifest[T].runtimeClass.getName + " hasn't been thrown"))
}
}https://stackoverflow.com/questions/46697948
复制相似问题