I meet a question about the mock private method in a injected mock annotated class. My code is like following
public class foo {
@Autowired
fooBean fooBean;
public void method1() {
this.method2();
}
private void method2() {
fooBean.someMethod();
system.out.println("Hello world");
}
}
when I create a UT class with powermockito, the foo class should be @injectMocks, since the fooBean should be injected as mock class. But when foo class is marked as @injectMocks, it can't be mock its private method using like "doReturn("xxx").when(foo,"method2")", it will raise error about this can not be applied to injectMocks.
It is blocked. Don't know how to continue.