1

At the moment I have following code:

val mockXmlRpc = mock[XmlRpcClient]
mockXmlRpc.execute("foo.",Array[Object]()).andReturn("").anyTimes()

During the test execute methid is called few times with different String arrays and I just need to return empty String to all of these calls.

How can I achieve this without writing custom matchers for each call?

2 Answers 2

2

Turns out there is a solution to this lurking in EasyMock documentation

mockXmlRpc.execute("foo.", isA(classOf[Array[Object]])).andReturn("").anyTimes()
1
  • I keep getting punted back to this old page although EasyMock is on 3.5 now and 'classOf' isn't available anymore. Does anyone have an updated answer?
    – k-den
    Sep 22, 2017 at 23:07
1

For a String array, do this:

mockXmlRpc.execute("foo.", EasyMock.anyObject(String[].class)).andReturn(someMockObj);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.