Mockito: Difference between doThrow() and thenThrow()
<p>What's the difference between <code>doThrow()</code> and <code>thenThrow()</code>?</p>

<p>Let's say, we want to mock an authentication service to validate the login credentials of a user. What's the difference between the following two lines if we were to mock an exception?</p>

<pre><code>doThrow(new BadCredentialsException("Wrong username/password!")).when(authenticationService).login("user1", "pass1");
</code></pre>

<p>vs</p>

<pre><code>when(authenticationService.login("user1", "pass1")).thenThrow(new BadCredentialsException("Wrong username/password!"));
</code></pre>