Answer the question
In order to leave comments, you need to log in
Is it possible to mock a local variable?
There is a class and a "problematic" method for testing:
MyClass() {
public void someMethod() {
private Problem problemVar = new ProblemVar();
...
}
}
Answer the question
In order to leave comments, you need to log in
I will assume that it is possible, using PowerMock.
ProblemVar pvMock = mock(ProblemVar.class);
whenNew(ProblemVar.class).withNoArguments().thenReturn(pvMock);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question