J
Janwillem Borleffs
Hello,
I want to partially mock a public class implementation. I'm mocking two
methods and call an unmocked third one, which calls upon the first two.
All's well, and the unittests succeed as expected. But I keep getting
annoying "wrong number of arguments" log messages thrown by the Reflection
API which is used in the background by EasyMock classextensions.
The code I'm using drills down to this:
// start code
Method[] methods = {
Object2Mock.class.getMethod("method1", String.class),
Object2Mock.class.getMethod("method2") // No arguments
};
Object2Mock object2mock = createMock(Object2Mock.class, methods);
expect(object2mock.method1("foo")).andReturn("bar");
expect(object2mock.method2()).andReturn("baz");
replay(object2mock);
object2mock.method3();
verify(object2mock);
// end code
I've also tried to pass the ConstructorArgs argument to the createMock()
method, to no avail. Please note that the usual way of handling these
situations (create an instance and pass the mocked object through one of the
instance methods) doesn't apply here, due to the class design.
I would appreciate any pointers.
TIA & Regards,
JW
I want to partially mock a public class implementation. I'm mocking two
methods and call an unmocked third one, which calls upon the first two.
All's well, and the unittests succeed as expected. But I keep getting
annoying "wrong number of arguments" log messages thrown by the Reflection
API which is used in the background by EasyMock classextensions.
The code I'm using drills down to this:
// start code
Method[] methods = {
Object2Mock.class.getMethod("method1", String.class),
Object2Mock.class.getMethod("method2") // No arguments
};
Object2Mock object2mock = createMock(Object2Mock.class, methods);
expect(object2mock.method1("foo")).andReturn("bar");
expect(object2mock.method2()).andReturn("baz");
replay(object2mock);
object2mock.method3();
verify(object2mock);
// end code
I've also tried to pass the ConstructorArgs argument to the createMock()
method, to no avail. Please note that the usual way of handling these
situations (create an instance and pass the mocked object through one of the
instance methods) doesn't apply here, due to the class design.
I would appreciate any pointers.
TIA & Regards,
JW