Is there a way to call a real method on a stubbed object with scalamock?
I would like to be able to do something like this:
class MySpec extends FunSpec with Matchers with MockFactory {
trait MyTrait {
def f1: Int
def f2: Int = f1
}
describe("my feature") {
it("should work") {
val t = stub[MyTrait]
(t.f1 _).when().returns(15)
// I would like to do the following:
// (t.f2 _).when().callRealMethod()
t.f2 should be (15)
}
}
}
Note: I was able to work around the issue by making f2
final but I would like to know if there is a way to do it without changing the code under test.