Is it possible to create a mock object that implements several interfaces with EasyMock?
For example, interface Foo and interface Closeable
To the best of my knowledge, the only mocking tool for Java that has explicit support for mocking multiple interfaces is JMockit. (My inspiration for adding this feature came from Moq and Rhino Mocks, which are .NET tools.)
An example (from the mockit.ExpectationsUsingMockedTest JUnit 4 test class):
@Test
public void mockParameterWithTwoInterfaces(final M mock)
{
new Expectations()
{
{
mock.doSomething(true); returns("");
mock.run();
}
};
assertEquals("", mock.doSomething(true));
mock.run();
}
Dependency and Runnable are interfaces. The doSomething method belongs to the first, and run to the second.