Multithreading 如何以编程方式使另一个线程的ScalateTest失败

Multithreading 如何以编程方式使另一个线程的ScalateTest失败,multithreading,scala,scalatest,Multithreading,Scala,Scalatest,据我所知,所有assert方法都会抛出由测试运行程序处理的异常。我正在测试多线程应用程序,希望将生成的线程中的错误传递给运行程序。我知道runner不能中断线程,所以我会手动关闭它们。但是我想将测试标记为失败。我认为您可以从scalatest中混合ScalaFuturestrait val f = Future.failed[Int](new RuntimeException) whenReady(f.failed) { e => assert(e.isInstanceOf[Runt

据我所知,所有assert方法都会抛出由测试运行程序处理的异常。我正在测试多线程应用程序,希望将生成的线程中的错误传递给运行程序。我知道runner不能中断线程,所以我会手动关闭它们。但是我想将测试标记为失败。

我认为您可以从scalatest中混合
ScalaFutures
trait

val f = Future.failed[Int](new RuntimeException)

whenReady(f.failed) { e =>
  assert(e.isInstanceOf[RuntimeException]
}

我在测试我自己的未来。这会发生冲突。现在我正在使用检查点。它们是线程安全的,因为它们基于并发集合