mockito when void throw code example Example: mockito throw exception void method doThrow(new Exception()).when(mockedObject).methodReturningVoid(...);