Is it possible to create a single mock object, that mocks multiple interfaces?
mock(First.class, Second.class) is obviously not supported.
Greetings,
Malte
I found a very simple solution: Create a new interface that extends
all the interfaces to mock:
public interface MockInterface extends First, Second {}
mock(MockInterface.class)
Greetings,
Malte
Summary from that is your suggestion will work, but some find it slightly ugly
and would prefer to use a method. Added advantage with the method call is
consistency.
Regards,
Graham
<T> T mock(Class<? extends T> ... classes) { ... }
Object mock = mock(String.class, Number.class, Comparable.class);
Can I actually define this as the type of my variable?
If not, the creation of a mock for several interfaces doesn't help,
because I can't access it other than Object.
Greetings,
Malte