Here is the details implementation on accessing private method through PowerMockito.
objectUnderTest = PowerMockito.spy(new TheRealImplementation());
PowerMockito.doNothing()
.when(objectUnderTest, PowerMockito.method(TheTargetClass.class, "thePrivateMethod"))
.withNoArguments();
Assuming TheRealImplementation class is as shown below:
public class TheRealImplementation {
private void thePrivateMethod() {
...
...
}
...
}

No comments:
Post a Comment