1
我想知道在μtest的scalatest中等效的recoverToSucceededIf。实际上,github页面显示了AFAIK是TestRunner方法的runAsync方法。如何使用utest在TestSuite中测试未来的失败?
问候
我想知道在μtest的scalatest中等效的recoverToSucceededIf。实际上,github页面显示了AFAIK是TestRunner方法的runAsync方法。如何使用utest在TestSuite中测试未来的失败?
问候
我当前创建的一个特点,延长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"))
}
}