My code structure is like below:
class A {
def a(x: () => Unit) { do something}
}
class B {
....
def foo() {
def x() { something }
a(x)
}
}
Now I want to do unittest of class B with a mock A.
val a = mock[A]
def x () { ... }
a.a(x) atLeastOnce
The above doesn't work. Since this new x is not the x inside foo(). But the x inside foo is a local one, not accessible to unittest. Any suggestion except to move x out of foo?