• Use ScalaFutures mixin
  • whenReady
  • when testing for failure pass futureValue.failure to whenReady
class FooTest extends WordSpec with MustMatchers with MockitoSugar with ScalaFutures {
...
  "Foo" can {
    "doSomething" should {
      "fail when something goes wrong" in {
        when(mockDependency.getQux(any[Bar], anyString()))
          .thenReturn(Future.successful(None))

        val result = doSomething(testCommand)

        whenReady(result.failed) { exception =>
          exception mustBe an [Exception]
        }
      }
    }
  }
}