Skip to content

Instantly share code, notes, and snippets.

@javaeeeee
Created January 10, 2015 13:21
Show Gist options
  • Save javaeeeee/39a5e30180f1ae659bfd to your computer and use it in GitHub Desktop.
Save javaeeeee/39a5e30180f1ae659bfd to your computer and use it in GitHub Desktop.
A Mockito test simulating exception
@Test
public void testShowBalance() throws BankServiceException {
//given
Mockito.when(bankService.getBalance())
.thenThrow(new BankServiceException());
//when
sut.showBalance();
//then
Mockito.verify(screen).displayError(ATM.BANK_SERVICE_ERROR);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment