nazymko / powermock

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

Create a "createMocksAndInjectTo(tested)" API method #155

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
This should automatically go through all fields in the tested instance and
mock all instance fields. E.g. if tested has two fields like this:

public class MyClassToTest {
   private Collaborator1 collabortator1;
   private Collaborator2 collabortator2;

  ...

}

then createAndInjectMocksTo(myClassToTest) should automatically creates
mocks for Collaborator1 and Collaborator2 and set them to the respective field.

For Mockito the method may be called something like "mockAndInjectTo".

Original issue reported on code.google.com by johan.ha...@gmail.com on 10 Sep 2009 at 6:47

GoogleCodeExporter commented 8 years ago
To only problem is how to get a hold of the mocks. Perhaps the method need to 
return
a "MockContext" with class as key and mock as instance? Or maybe it's just 
better to
use Whitebox.setInternalStateFromContext(..) on the tested instance?

Original comment by johan.ha...@gmail.com on 10 Sep 2009 at 9:10