In PowerMockito, we can use the pattern "whenNew(MyClass).thenReturn(mockMyClass)" when someone wants to new an instance of MyClass, it will receive mockMyClass instead of the real instance.
Can we do similar things in ScalaMock or EasyMock? I spent whole day for this issue.
This is my scenario, I have two classes A and B. Inside class A, it will new an instance of class B.
Now I want to test class A, and when class A creates a new instance of class B, what I want is to return a mock object of class B (not the real class B).
In Java, I can handle this issue easily with PowerMock and JUnit, but I cannot do it in Scala.