Test that void method didn't get called with EasyMock

nkr1pt picture nkr1pt · Sep 14, 2010 · Viewed 16.8k times · Source

Is this possible? I tried with EasyMock.expectLastCall().times(0); but EasyMock complains that times must be >=1

Answer

Dawood ibn Kareem picture Dawood ibn Kareem · Jan 16, 2013

You could use .andThrow(new AssertionFailedError()).anyTimes(); - this is the same exception that Assert.fail() throws, but is less verbose than making an Answer.