Given a Scala trait with a method that has a call-by-name parameter, e.g.
trait Foo {
def bar(a: => String)
}
Mock and verify the method:
val foo = mock[Foo]
foo.bar("BAZ")
verify(foo).bar(anyString)
I would expect this to pass. It actually fails, as it is comparing the lambda
that generates the parameter.
There is a painful workaround, that involves creating an anonymous Function
object to represent the parameter lambda, then override the equals method to
evaluate the function and compare results (see
http://stackoverflow.com/a/2158709/323177)
This uses Scala 2.10.0 and Mockito 1.9.0.
Original issue reported on code.google.com by richardw...@googlemail.com on 12 Jun 2013 at 11:45
Original issue reported on code.google.com by
richardw...@googlemail.com
on 12 Jun 2013 at 11:45