I am using specs2 as my test framework. I want to simulate a use case in which actionA return a failing future. Like this:
val actionA = mock[ActionA]
val actionB = new ActionB(actionA)
actionA.doSomthing(x) returns Future.failed(new Exception("bla"))
try {
Await.result(actionB.doSomthing(request), 1 seconds)
}catch {
case e: Exception => println("exception caught: " + e);
}
The problem is that my test exit with this exception if I am not catching it, doesn't specs2 have a nicer way to swallow exceptions? Is there a better way to test such scenario?
Thanks!
Aucun commentaire:
Enregistrer un commentaire