ahmaddarawshi / powermock

Automatically exported from code.google.com/p/powermock
0 stars 0 forks source link

Implement a Whitebox.setInternalStateFromContext #128

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Let's say we have a class that has many collaborators that needs to be
mocked. One nice feature would be to be able to do something like this in
the setup method:

tested = new MyClassToTest(); // MyClassToTest has many collaborators
Whitebox.setInternalStateFromContext(tested, this);

What setInternalStateFromContext will do is to go through all fields
defined in "this" (e.g. the test) and set them on tested. This means that
we don't need to do Whitebox.setInternalState(tested, myCollaborator1);,
..,  Whitebox.setInternalState(tested, myCollaboratorN) when the
collaborators are defined in the test case already.

Original issue reported on code.google.com by johan.ha...@gmail.com on 3 Jul 2009 at 12:58

GoogleCodeExporter commented 9 years ago

Original comment by johan.ha...@gmail.com on 14 Jul 2009 at 5:19

GoogleCodeExporter commented 9 years ago

Original comment by johan.ha...@gmail.com on 22 Jul 2009 at 8:51