mercredi 4 février 2015

Catch exception in Play 2 Test + Futures

how do I catch an exception inside a future success using play to test?


Here is my code:



"A Validity" should {
"be created based on Client's Mobile" in new WithApplication {
val objectId = UUIDs.timeBased()
CValidityServiceModule.checkValidity(true, "MOBILE", clientId, objectId)
val future = genericService.findByObjectIdAndByClientId(objectId, clientId)

future.onComplete {
case Success(s) => {
s match {
case Some(v) => {
v.clientId mustEqual clientId
v.objectId mustEqual objectId
}
case None => assert(false)
}
}
case Failure(t) => {
assert(false, t.getMessage)
}
}
}


Basically if any matcher fail, it trows me an exception, but the test is green.


Any idea?


Aucun commentaire:

Enregistrer un commentaire