A method to mock a new instance in the class is using the powermockito. Powermockito has a function whenNew. This one can be used to solve this kind of problem.

what is the mainly characters of Object oriented programming language

Nowadays, the concept of the Object oriented programming becomes more and more popular. What is the mainly characters of it?

Speed up webpage testing time

Testing web pages can be really time consuming. Every CSS, HTML or image change needs a browser refresh. It would be way better if the reloads could be avoided.


Whitebox.setInternalState(Foo.class, b);

Works as long as you set a non-null value, and if theres only one field with the class of B. If you can't rely on that luxury, you have to provide the field-name and cast the null to the type you want to set. In that case you would need to write something like this:

Whitebox.setInternalState( Foo.class, "b", (B)null );


Subscribe to programming