在您指向文档之前,请指出这个最小的失败示例有什么问题:
import org.scalatest.FlatSpec
import org.scalamock.scalatest.proxy.MockFactory
class StubbingTest extends FlatSpec with MockFactory {
trait Foo {
def f(x: Int): Int
}
"foo" should "stub" in {
val foo = stub[Foo]
(foo.f _).when(3).returns(4)
assert(foo.f(3) == 4)
}
}
结果在java.lang.NoSuchMethodException: com.sun.proxy.$Proxy4.mock$f$0()
第 11 行:(foo.f _).when ...
根据文档,这应该有效。我在这里想念什么?