I would like to know how to mock a method which is called in many places in my android project. For instance I have this class:
public class RequestQueue {
protected RequestQueue mRequestQueue;
protected Context mCtx;
public RequestQueue(Context context) {
...
}
public void addRequestToQueue(BaseRequest request) {
...
}
}
and this one:
public class FakeRequestQueue extends RequestQueue {
public FakeRequestQueue(Context context, int expectedRetCode) {
super(context);
...
}
@Override
public void addRequestToQueue(BaseRequest request) {
...
}
}
What I want is to replace all the calls to RequestQueue.addRequestToQueue()
by FakeRequestQueue.addRequestToQueue()
in my whole project. I understand the mock concept but what I found until now is only a way to mock objects locally instantiated.
Thank you.