How I can mock a field variable which is being initialized inline?
class Test {
private Person person = new Person();
...
public void testMethod() {
person.someMethod();
...
}
}
Here I want to mock person.someMethod()
while testing the Test.testMethod()
method for which I need to mock initialization of person
variable. Any clue?
Edit: I'm not allowed to modify Person class.