def futureValue(implicit config: Futures.PatienceConfig): T
Returns the result of thisFutureConcept
, once it is ready, or throws either the exception returned by the future (i.e.,futureValue
returned aLeft
) orTestFailedException
.
class TestException() extends RuntimeException("Expected in test")
object ExampleCode {
def execute()(implicit ec: ExecutionContext): Future[String] = {
Future { throw new TestException() }
}
}
a[TestException] should be thrownBy(ExampleCode.execute().futureValue)
-> Expected exception TestException to be thrown, but org.scalatest.exceptions.TestFailedException was thrown. (ExampleTest.scala:10)
The future returned an exception of type: TestException, with message: Expected in test. (ExampleTest.scala:13)