scala test: verify using functions as parameters

95 views Asked by At

I am trying to use verify on a mocked object's method, where it receives two parameters, one of them a String and the other one a function. So basically in my test i have:

verify(mockedObj).someMethod(aString, theFunction _)

theFunction is defined in an object. The error I am getting is the following:

Argument(s) are different! Wanted:
mockedObj.someMethod(
    "theFunction",
    ($anonfun$apply$mcV$sp$2) <function1>,
    TypeTag[String],
    TypeTag[String]
);
-> at  bla.TestClass$$anonfun$2$$anonfun$apply$mcV$sp$1.apply$mcV$sp(TestClass.scala:28)
Actual invocation has different arguments:
mockedObj.someMethod(
    "theFunction",
    (anonfun$someMethod$1) <function1>,
    TypeTag[String],
    TypeTag[String]
);
-> at bla.RealObject$.someMethod(RealObject.scala:17)

Any clues on how could I actually perform this?

Thanks!!

0

There are 0 answers