I have a method that invokes other method in the same class such as:
Class MyClass{
public int methodA(){
...
methodB()
...
}
public int methodB(){
...
}
}
And I just wanna test methodA()
, so how can I isolate methodB()
using EasyMock
.
My damn way is to create a fake instance of MyClass
and inject it into the methodA()
like this:
public int methodA(MyClass fake){
...
fake.methodB();
...
}
and expect it in my testcase:
MyClass fake = EasyMock.createMock(MyClass.class);
EasyMock.expect(fake.methodB()).andReturn(...);
Is there any better solution for this situation?