title: Mockito Thread.class exception in try catch block does not improve coverage
body: <p>I am trying to test exception in try catch block with Thread.sleep method in try block using Mocito. I used below mockito test method and it passes as expected but never improves my test coverage. The coverage report shows the catch block inside waitForSync method never reached. Can anyone please help what is that I am missing here?</p>
  
  <pre><code>public class CreateAccount{
  @Autowired
  private AccountService accountService,
  
  @Autowired
  private BuildAccountResponse buildAccountResponse
  
   @Value("${waitForSync:0}")
    private Integer accountSyncWaitTimeMs;
  
  public AccountResponse createMyAccount(AccountRequest request, String accountId) {
  
      accountService.checkIfAccountExists(accountId);
  
     Optional&lt;AccountResponse&gt; myResponse= buildAccountResponse.create(request, accountId);
  
     waitForSync(accountId);
  
     return myResponse.get();
  }
  }
  
  </code></pre>
  
  <p>waitForSync method</p>
  
  <pre><code>private void waitForSync(String accountId) {
  try{
  if (accountSyncWaitTimeMs&gt;0){
  Thread.sleep(accountSyncWaitTimeMs)
  }
  catch { (Exception e)       
  Logger.warn("Failed to apply wait account sync");   
  
  }
  </code></pre>
  
  <p>My mockito test method</p>
  
  <pre><code>@InjectMocks
  @Spy
  private CreateAccount createAccount;
  
  private static final accountWaitTime = 1;
  
  ReflectionTestUtils.setField(createAccount, "accountSyncWaitTimeMs" , accountWaitTime);
  
  private AccountRequest request;
  
  private static final String accountId = "AccountId";
  
  @Test (expected = Exception.class)
  public void createAccount_waiSync_Exception () {
  
   doThrow(new InterruptedException()).when(Thread.class);
  
  createAcccount.createMyAccount(request, accountId);
  }
  
  </code></pre>
  
  <p>Test passes as expected but below lines are never covered, so basically I added test for nothing when it comes to coverage, so how shall improve it?</p>
  
  <pre><code>catch { (Exception e)       
  Logger.warn("Failed to apply wait account sync"); 
  </code></pre>