Is there something like a "really nice mock"?

by Chris   Last Updated May 17, 2019 09:26 AM

Nice mocks in both EasyMock and Mockito are a good thing to start with if you do not want to define behaviour for everything and if you do not want to restrict calls on that mock.

But for me they have one big flaw: They always return null if the return type of the method is Object or anything inheriting from Object.

I am wondering if there is something in one or both of the frameworks that returns Optional.empty() for methods that return Optional<?> or Collections.emptyList() for methods that return List<?> and so on...

I wasn't yet able to find anything like this.



Related Questions


Updated November 27, 2017 13:26 PM

Updated August 04, 2015 13:11 PM

Updated May 10, 2017 18:26 PM

Updated March 22, 2017 14:26 PM

Updated October 07, 2017 19:26 PM