0

As far as I know all assert methods throws exceptions that are handled by the test runner. I'm testing mutlithread application and would like to pass errors from spawned threads to the runner. I understand that runner could not interrupt threads, so I would shutdown them manually. But I would like to mark the test as failed.

ayvango
  • 5,867
  • 3
  • 34
  • 73

1 Answers1

0

I think you can mixin ScalaFutures trait from scalatest.

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

whenReady(f.failed) { e =>
  assert(e.isInstanceOf[RuntimeException]
}
rahilb
  • 726
  • 3
  • 15
  • I'm testing my own futures. That would collide. For now I'm using checkpoints. They are threadsafe because they based on concurrent collection – ayvango Oct 26 '15 at 13:58