dimanche 4 octobre 2015

Scala and mockito to test twilio MessageFactory.create() method

I'd like to test our Twilio integration using some simple dependency injection and mocking. It seems to me the easiest method would be to use mockito to intercept the following message create call:

val messageFactory: MessageFactory = smsProvider.getAccount().getMessageFactory()
val message: Message = messageFactory.create(params)

Ideally I'd like to stub out the create call so that I can validate that it was called, and that the parameters are correct.

I'm new to Mockito though, and trying to piece together how to use it in Scala (and if this kind of testing is even possible). Most examples I've found are in Java, etc., and don't translate well to Scala.

Aucun commentaire:

Enregistrer un commentaire