When you have written a few tests using Easymock you might get into the fun situation that you need to mock a method that returns void and you want the method to throw an exception. What do you do?
Usually you would write something like:
expect(mockSender.send(message)).andThrow(new Exception());
But this does not work with void methods because expect() cannot work with a void return value.
Solution
Use expectLastCall():
mockSender.send(message);expectLastCall().andThrow( new SendFailedException("Error"));