After reading: https://code.google.com/p/powermock/wiki/BypassEncapsulation i realized, i don't get it.
See in this example:
public class Bar{
private Foo foo;
public void initFoo(){
foo = new Foo();
}
}
How can i access the private member foo
by using PowerMock (For example to verify that foo
is not null)?
Note:
What i don't want is modifying the code with extra get
methods.
Edit:
I realized that i missed a sample code block on the linked page with the solution.
Solution:
Whitebox.getInternalState(bar, "foo");
That should be as simple as writing the following test class:
Adding the right (static) imports is left as an exercise to the reader :).