Is this possible? I tried with EasyMock.expectLastCall().times(0);
but EasyMock complains that times must be >=1
andVoid() If we just want to mock void method and don't want to perform any logic, we can simply use expectLastCall(). andVoid() right after calling void method on mocked object. You can checkout complete project and more EasyMock examples from our GitHub Repository.
The API doc for EasyMock says this about expectLastCall() : Returns the expectation setter for the last expected invocation in the current thread. This method is used for expected invocations on void methods. java unit-testing easymock.
Once created, a mock is in “recording” mode, meaning that EasyMock will record any action the Mock Object takes, and replay them in the “replay” mode. expect(…): with this method, we can set expectations, including calls, results, and exceptions, for associated recording actions.
You could use .andThrow(new AssertionFailedError()).anyTimes();
- this is the same exception that Assert.fail()
throws, but is less verbose than making an Answer
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With