Writing Unit Test for Failsafe Retry and Timeout policy

774 views Asked by At

Using Failsafe by jhalterman for the first time ( GIT, Website ) to add a simple asynchronous module to send sms. I am using only Retry and Timeout policy and implementation is working fine

Failsafe.with(timeoutPolicy, retryPolicy)
    .with(getExecutorService())
    .runAsync(() -> sendSMS(msg, mobile));

Now I am struggling to write a unit test case for this.

How can I mock a failure to retry or timeout to write tests like sendSmsOneRetry, sendSmsTwoRetry or sendSmsTimeout?

I have Mockito available too in project.

0

There are 0 answers